Docker似乎是在服务器上迁移数据库,而不是在RDS上迁移

我很抱歉,如果我的问题似乎微不足道,但我是一个总noob,当涉及到部署我的rails应用程序。

我试图在弹性beanstalk上使用docker部署我的应用程序。 但部署失败的数据库迁移。 我得到这个消息: 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"? 我正确的想,docker是试图本地连接到PostgreSQL吗?

我没有看到如何告诉docker连接到RDS,因为我的database.yml文件已经指向我的RDS数据库。 另外这里是我的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 http://apt.postgresql.org/pub/repos/apt/ 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 

和我的database.yml文件:

 production: 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'] %> 

非常感谢您的帮助,但我找不到相关的修复程序,

最好,

托马斯

对于那些可能遇到同样问题的人来说,这与docker无关,而是与active_records有关,意味着你的rails应用程序无法连接到你的RDS数据库。 在我的情况下,问题是在database.yml文件中指定“hostname”而不是“host”。