I am working on an Apple M1 Pro and running onto several issues with Docker and chromedriver.
So I want to run RSpec tests with selenium chrome headless on my Docker container. My Dockerfile is:
# Start from the official ruby image, then update and install JS & DB
FROM --platform=linux/amd64 ruby:2.6.6
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
# Install Chromedriver
RUN apt-get update && apt-get install -y unzip && \
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/ && \
unzip ~/chromedriver_linux64.zip -d ~/ && \
rm ~/chromedriver_linux64.zip && \
chown root:root ~/chromedriver && \
chmod 755 ~/chromedriver && \
mv ~/chromedriver /usr/bin/chromedriver && \
sh -c 'wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
apt-get update && apt-get install -y google-chrome-stable
# Create a directory for the application and use it
RUN mkdir /myapp
WORKDIR /myapp
# Gemfile and lock file need to be present, they'll be overwritten immediately
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
# Install gem dependencies
RUN gem install bundler:2.2.32
RUN bundle install
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
apt-get install nodejs
COPY . /myapp
# This script runs every time the container is created, necessary for rails
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start rails
CMD ["rails", "server", "-b", "0.0.0.0"]
My docker-compose.yml is:
version: "3"
services:
db:
image: postgres
environment:
POSTGRES_USER: yyy
POSTGRES_PASSWORD: xxx
volumes:
- ./tmp/db:/var/lib/postgresql/data
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
environment:
POSTGRES_USER: yyy
POSTGRES_PASSWORD: xxx
POSTGRES_HOST: db
My capybara.rb:
require 'capybara/rspec'
require 'selenium-webdriver'
Capybara.register_driver :selenium_chrome_headless do |app|
Capybara::Selenium::Driver.new app,
browser: :chrome,
clear_session_storage: true,
clear_local_storage: true,
capabilities: [Selenium::WebDriver::Chrome::Options.new(
args: %w[headless disable-gpu no-sandbox window-size=1024,768],
)]
end
Capybara.javascript_driver = :selenium_chrome_headless
and Gemfile:
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara'
gem 'launchy', '~> 2.4.3'
gem 'selenium-webdriver'
#To clean database for tests
gem 'database_cleaner'
# Easy installation and use of web drivers to run system tests with browsers
# gem 'webdrivers'
end
This installs the chromedriver and google-chrome-stable in the /usr/bin directory in the container:
# which chromedriver
/usr/bin/chromedriver
# which google-chrome-stable
/usr/bin/google-chrome-stable
And their version matches (I read online that if it doesn't match it gives problems):
# google-chrome-stable --version
Google Chrome 98.0.4758.80
# chromedriver --version
ChromeDriver 98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758#{#972})
So it should be working. When I try to run the test, when the test is using js:true and I am in need of a headless chrome, this error happens:
Selenium::WebDriver::Error::UnknownError:
unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I have been searching around but I found nothing that can help since I have the M1 chip and the answers I found didn't work.
NOTE:
Don't know if it is helpful but when I enter the container and try to run chromedriver it goes right but when running google-chrome-stable an error occurs:
# google-chrome-stable
[57:57:0210/020137.011691:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
# google-chrome-stable --no-sandbox
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[129:129:0210/020150.185829:ERROR:nacl_fork_delegate_linux.cc(329)] Bad NaCl helper startup ack (0 bytes)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[93:137:0210/020150.317808:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
[0210/020150.398311:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Function not implemented (38)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
Trace/breakpoint trap
I have been going around this for a long time. Do you have any idea how to solve? Thanks!
For solving the chrome and chromedriver issue in mac m1 arm64:
You can use the following docker image seleniarm/standalone-chromium:latest for arm64 architecture to run your system test using the open source Chromium browser.
seleniarm/standalone-chromium:latest
Related
Trying to run a ruby on rails app, here is the docker-compose.yml:
version: '3'
services:
postgres:
image: postgres:11
volumes:
- ./tmp/db:/app/tmp/db
environment:
POSTGRES_HOST_AUTH_METHOD: trust
app:
build: .
command: bash -c "yarn install --check-files ; rm -f tmp/pids/server.pid ; /app/bin/webpack-dev-server --host 0.0.0.0 & bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/app
- /home/$USER/.ssh:/root/.ssh
ports:
- "3000:3000"
- "3035:3035"
depends_on:
- postgres
- solr
solr:
image: solr:8.2
And here is the Dockerfile:
FROM <OMITTED>/ruby_2.5.1:latest
MAINTAINER <OMITTED>
# Install apt-get dependencies and nodejs
RUN apt-get update && apt-get install -y \
build-essential
# Set working directory for following commands
RUN mkdir -p /app
WORKDIR /app
# Copy Gemfile and then install gems through bundler
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install
# Installing nodejs, yarn, and the java runtime environment
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN apt-get update && apt-get install -y yarn postgresql-client-12
RUN yarn install --check-files
RUN apt-get install -y default-jre ffmpeg nano
RUN apt-get install -y ruby-chromedriver-helper
# Copy the main application.
COPY . ./
# Start SSH agent and add key
RUN echo 'eval "$(ssh-agent -s)" &>/dev/null' >> ~/.bashrc
RUN echo 'ssh-add $(find /root/.ssh -type f ! -name "*.*" | grep id) &>/dev/null' >> ~/.bashrc
RUN yarn install --check-files
#Searches in the /.ssh directory in the container for files that do not have an extension,
#searches them for 'id' which will be a key, and then adds to the ssh agent
RUN ln -sf /usr/local/rvm/rubies/ruby-2.5.1/bin/* /usr/local/bin
# Expose port 3000 so it can be seen outside of the container
EXPOSE 3000
EXPOSE 3035
# Run the rails server
CMD ["rails", "server"]
The project is a pretty standard ruby on rails app; it uses postgresql for the database, solr for search functionality on the website, and yarn for javascript packages. When I run docker-compose up, the project builds successfully (gets through all 25 steps in the Dockerfile), the solr and postgresql images start up fine, but when it comes to the web app itself I get this error:
app_1 | yarn install v1.22.18
app_1 | Error: EACCES: permission denied, open '/app/package.json'
app_1 | at Object.openSync (fs.js:462:3)
app_1 | at Object.readFileSync (fs.js:364:35)
app_1 | at onUnexpectedError (/usr/share/yarn/lib/cli.js:88608:106)
app_1 | at /usr/share/yarn/lib/cli.js:88727:9
app_1 | bash: line 1: /app/bin/webpack-dev-server: Permission denied
app_1 | Your RubyGems version (3.0.9) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
app_1 | Could not locate Gemfile or .bundle/ directory
<OMITTED>-rails_app_1 exited with code 10
I've tried so far:
Setting permissions (sudo chown -R $USER:$USER . and variations)
Pruning docker (running docker system prune -a)
Changing git branches (I originally thought it was some code on my feature branch causing an issue)
Rebooting computer and updating packages
None of these have remedied the issue.
Summary: works on the mac but not on windows. Please note: This is not a duplicate of other similar issues, I have researched this for more than a day on SO and elsewhere.
I built a super simple script which executes 2 dockers containers: one with chrome browser, chromedriver and the other with the test. It runs fine on Linux, but when I launch the containers on Windows I'm getting;
root#4ba2401510ed:/wdir# ../usr/bin/php7.1 chromeTest.php
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownErrorException: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has
crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '5cc73cb1d7df', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.72-microsoft-standard-WSL2', java.version: '1.8.0_282'
Driver info: driver.version: unknown
remote stacktrace: #0 0x564b66a6ce89 <unknown>
in /wdir/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:139
Stack trace:
#0 /wdir/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php(371): Facebook\WebDriver\Exception\WebDriverException::throwException('unknown error', 'unknown error: ...', Array)
#1 /wdir/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(135): Facebook\WebDriver\Rem in /wdir/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php on line 139
Has anyone seen this before? It looks like Docker just behaves differently on Windows and makes the Chrome inside the docker container crash..
I tried proposed solutions such as adding --headless, --sandbox, etc. but it really seems to be something with the way docker works on windows.
Yaml file
version: '3.4'
services:
# Contains the chrome browser, chromedriver
chrome:
image: selenium/standalone-chrome-debug
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
- "5900:5900"
# Contains PHP webdriver library
php7:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- .:/wdir/
depends_on:
- chrome
command: tail -F anything
Dockerfile
FROM scratch
ADD ubuntu-xenial-core-cloudimg-amd64-root.tar.gz /
ADD start.sh /
# Chromium DEB file
#ADD google-chrome-stable_90.0.4430.85-1_amd64.deb /
#ADD chromedriver /
# ADD firefox_88.0-1_i386.deb /
# a few minor docker-specific tweaks
# see https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap
RUN set -xe \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L40-L48
&& echo '#!/bin/sh' > /usr/sbin/policy-rc.d \
&& echo 'exit 101' >> /usr/sbin/policy-rc.d \
&& chmod +x /usr/sbin/policy-rc.d \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L54-L56
&& dpkg-divert --local --rename --add /sbin/initctl \
&& cp -a /usr/sbin/policy-rc.d /sbin/initctl \
&& sed -i 's/^exit.*/exit 0/' /sbin/initctl \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L71-L78
&& echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L85-L105
&& echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean \
&& echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean \
&& echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L109-L115
&& echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L118-L130
&& echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes \
\
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L134-L151
&& echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests
# this forces "apt-get update" in dependent images, which is also good
# (see also https://bugs.launchpad.net/cloud-images/+bug/1699913)
# make systemd-detect-virt return "docker"
# See: https://github.com/systemd/systemd/blob/aa0c34279ee40bce2f9681b496922dedbadfca19/src/basic/virt.c#L434
RUN mkdir -p /run/systemd && echo 'docker' > /run/systemd/container
# Install updates
RUN apt-get update -y && apt-get install -y software-properties-common language-pack-en-base \
\
# Install Java
-y default-jre \
\
# Install snapd
-y snapd \
\
# Install wget
-y wget \
-y lsof
# Clean up
RUN rm -rf /var/lib/apt/lists/*
# Get the PHP library
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get -y update && apt-get install -y \
php7.1 \
php7.1-pgsql \
php-pear \
php7.1-curl \
php7.1-sqlite3 \
php7.1-xml \
php7.1-bcmath \
php7.1-zip \
php7.1-mbstring \
php-xdebug \
php7.1-mysqli \
php-ast
# Define the working directory for this container
WORKDIR /wdir
# RUN chmod +x ./start.sh
CMD ["start.sh"]
It could be due to issues occurred when a windows update and docker image not updated accordingly. Try rolling back to a previous version can fix it.
Further, try experimenting with different docker images like
"selenium/standalone-chrome"
will help to debug the issue.
Example of a previous image which worked before the windows WSL update
image: selenium/standalone-chrome:89.0.4389.90-chromedriver-89.0.4389.23-20210315
Some options may need to be tweaked also while instantiating the driver object, here's a working example
$options = new ChromeOptions();
$options->addArguments(["no-sandbox","headless", "disable-dev-shm-usage"]);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY_W3C, $options);
$driver = RemoteWebDriver::create($host, $capabilities);
i am a newby in docker and I need an installation based on ubuntu of logstash.
I try the official logstash image and without success I can't run it so I decided to build my own installation based on my needs.
It works well but takes a lot of time to build it.
I wonder how can I improve (speed up) my building
This is my Dockerfile
FROM ubuntu:18.04
# RUN adduser --disabled-password --gecos "" ubuntu
# RUN usermod -aG sudo ubuntu
# RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN apt-get update && \
apt-get autoclean && \
apt-get autoremove
RUN echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
RUN apt-get install curl ca-certificates apt-utils wget apt-transport-https default-jre gnupg apt-transport-https software-properties-common -y
# RUN update-alternatives --config java
ENV LANG C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN apt update
RUN apt install ruby-full -y
RUN ruby --version
RUN apt install jruby -y
#install jruby (last version)
RUN jruby --version
RUN apt install logstash
#install plugins and bundles.
RUN cd /usr/share/logstash && gem install bundler
COPY logstash-pcap-test.conf /usr/share/logstash/
RUN mkdir /home/logstash/ && mkdir /home/logstash/traffic
COPY /traffic-example/* /home/logstash/traffic/
WORKDIR /usr/share/logstash
CMD ["/bin/bash","-c","bin/logstash -f logstash-pcap-test.conf --config.reload.automatic"]
And this is my docker-compose
version: "3"
services:
logstash_test:
build:
context: .
dockerfile: container/Dockerfile
image: logstash_test:latest
container_name: logstash_test
hostname: logstash_test
ports:
- 9600:9600
- 8089:8089
networks:
- elknetwork
networks:
elknetwork:
driver: bridge
Any thoughts?
I'm learning how to build a rails application using docker, and each time I attempt to run $ docker-compose build web I get the following error:
You must use Bundler 2 or greater with this lockfile.
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 20
This is my Dockerfile:
FROM ruby:2.5.1
ENV APP_HOME /usr/src/app
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y nodejs
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn
# SOURCE CODE
WORKDIR $APP_HOME
COPY . $APP_HOME/
RUN gem install bundler --version 2.0.2 --no-rdoc --no-ri
ADD Gemfile $APP_HOME/
ADD Gemfile.lock $APP_HOME/
RUN bundle install
RUN echo '--color' >> ~/.rspec
This is my docker-compose.yml file
version: '3'
services:
db:
image: postgres
webpacker:
build: .
command: bundle exec bin/webpack-dev-server
volumes:
- .:/fancyapp
ports:
- "8080:8080"
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/fancyapp
ports:
- "3000:3000"
depends_on:
- db
- webpacker
I'm a complete noob with docker and I honestly can't see what's wrong here.
I'm basing my implementation on this tutorial
Run the command gem list bundler, I guess your bundler version is less than version 2.
If so, run gem install bundler -v 2.0.2 to install the latest one.
You can run gem install --default bundler -v 2.0.2 to make it the default version to be used.
It seems like in your Gemfile.lock says that you use bundler with version higher than 2. In this case you you can use 2 ways:
decrease your local version
add to your docker file string gem install bundler (without version). It will install last bundler
I am developing a web app using play fraework2.6. I am trying to have java8, postgres and nginx in my dockerfile. Here's the docker file:
FROM ubuntu:14.04
#INSTALL
RUN \
echo "deb http://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list \
&& sudo apt-get update -y --force-yes \
&& sudo apt-get install -y --force-yes sbt
RUN apt-get update && apt-get -y upgrade && apt-get -y install software-properties-common && add-apt-repository ppa:webupd8team/java -y && apt-get update
RUN (echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections) && apt-get install -y oracle-java8-installer oracle-java8-set-default
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV PATH $JAVA_HOME/bin:$PATH
ENV SBT_OPTS="-Xmx2048M"
ENV SBT_OPTS="-XX:MaxPermSize=2048m"
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.3``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python-software-properties postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Install Nginx
RUN sudo apt-get install -y nginx
# RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
# then create a database `docker` owned by the ``docker`` role.
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
# allows the RUN command to span multiple lines.
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER crm_play WITH SUPERUSER PASSWORD 'prod#123';" &&\
createdb -O crm_play crm_play
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
# CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
WORKDIR /java/src/project
RUN sbt update
EXPOSE 9000
ENTRYPOINT ["sbt", "run"]
COPY . /java/src/project
First of all is this the correct way to do this. Also build takes too much of time to build. I am building like this:
docker build -t image:tag .
build downloads all dependencies in sbt and other dependencies mentioned in docker file. After that I run
docker run -it -p 9000:9000 image:tag
It again starts downloading all the dependencies. What I am doing wrong here?