Docker seems to be migrating database on the server instead of migrating on RDS

I apologize if my question seems trivial but I am a total noob when it comes to deploying my rails app.

I’m trying to deploy my app using docker on elastic beanstalk. But the deployment fails on the db migration.
I get this message:
Docker container quit unexpectedly after launch: directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Am I right thinking that docker is trying to connect locally to postgresql?

  • Dockerized Gitlab Container Backup
  • Can I connect to remote DB server from inside docker container?
  • Docker for Mac: Using Persistent Storage
  • what is the correct way to set up puma, rails and nginx with docker?
  • Passing environmental variables when deploying docker to remote host
  • Connect to postgresql container from another container (Docker)
  • I don’t see how to tell docker to connect to RDS as my database.yml file is already pointing at my rds database.
    Also here is my dockerfile:

    FROM seapy/ruby:2.2.0
    RUN apt-get update
    # Install nodejs
    RUN apt-get install -qq -y nodejs
    # Intall software-properties-common for add-apt-repository
    RUN apt-get install -qq -y software-properties-common
    # Install Nginx.
    RUN add-apt-repository -y ppa:nginx/stable
    RUN apt-get update
    RUN apt-get install -qq -y nginx
    RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
    RUN chown -R www-data:www-data /var/lib/nginx
    # Add default nginx config
    ADD nginx-sites.conf /etc/nginx/sites-enabled/default
    # Install foreman
    RUN gem install foreman
    # Install the latest postgresql lib for pg gem
    RUN echo "deb trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
        apt-get update && \
        DEBIAN_FRONTEND=noninteractive \
        apt-get install -y --force-yes libpq-dev
    # Install paperclip dependencies
    RUN apt-get install -qq -y  ImageMagick    
    # Copy gemfile and bundle in temporary
    WORKDIR /tmp
    ADD Gemfile Gemfile
    ADD Gemfile.lock Gemfile.lock
    RUN bundle install -j 4
    # Copy app and precompile assets
    RUN mkdir /app
    ADD . /app
    WORKDIR /app
    ENV RAILS_ENV production
    RUN bundle exec rake assets:precompile
    # Nginx
    ADD nginx-sites.conf /etc/nginx/sites-enabled/default
    EXPOSE 80
    CMD bundle exec rake db:migrate && foreman start -f Procfile

    And my database.yml file:

      adapter: postgresql
      encoding: utf-8
      database: <%= ENV['RDS_DATABASE_NAME'] %>
      username: <%= ENV['RDS_DATABASE_USERNAME'] %>
      password: <%= ENV['RDS_DATABASE_PASSWORD'] %>
      hostname: <%= ENV['RDS_HOSTNAME'] %>
      port: <%= ENV['RDS_PORT'] %>

    Many thanks in advance for your help but I couldn’t find a relevant fix yet,



  • Docker - check private registry image version
  • I can't set up Kubernetes in Centos 7: Unable to update cni config
  • How to replicate microservices when consuming same kafka topic?
  • TFS workspace with Jenkins Docker container
  • How can I restart a docker image instead of restarting docker?
  • Gunicorn is stuck on docker run command with a Flask Application
  • One Solution collect form web for “Docker seems to be migrating database on the server instead of migrating on RDS”

    For those who might get into the same issue, this is not related to docker but to active_records and means your rails app can not connect to your RDS database.
    In my case the issue was specifying a ‘hostname’ instead of ‘host’within the database.yml file.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.