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?

  • How to get and present docker states inside html page by javascript?
  • Spring Boot with MongoDB on Docker
  • Get cpu usage from Java API 1.13 for docker 1.1.2
  • Mounting multiple volumes on a docker container?
  • Docker Image layers and ENTRYPOINT sequence
  • docker-compose: reinitializing MySQL db every time
  • 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 - Using Composer inside PHP container
  • Script to clone/snapshot Docker Containers including their Data?
  • How docker manage volumes when scaling up compose project?
  • How do I make a standalone application out of a Docker container?
  • Why “Data Space Used” + “Data Space Available” != “Data Space Total” in docker?
  • Docker logs not showing colors (express + nodejs image)
  • 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.