【发布时间】:2016-01-21 13:12:43
【问题描述】:
我正在尝试为开发环境运行 docker 容器。我正在使用下面的 docker 文件
FROM phusion/passenger-ruby22:latest
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# Expose Nginx HTTP service
EXPOSE 80
# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Add the nginx site and config
ADD nginx.conf /etc/nginx/sites-enabled/webapp.conf
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf
# Install bundle of gems
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install
# Add the Rails app
ADD . /home/app/webapp
RUN chown -R app:app /home/app/webapp
# Clean up APT and bundler when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
nginx.conf 如下
# webapp.conf
server {
listen 80;
server_name localhost;
root /home/app/webapp/public;
passenger_enabled on;
passenger_user app;
passenger_ruby /usr/bin/ruby2.2;
}
Rails Env 文件如下,
# rails-env.conf
# Set Nginx config environment based on
# the values set in the .env file
env PASSENGER_APP_ENV;
env RAILS_ENV;
env SECRET_KEY_BASE;
env APP_DEV_DB_HOST;
env APP_DEV_DB_DATABASE;
env APP_DEV_DB_PORT;
env APP_DEV_DB_USERNAME;
env APP_DEV_DB_PASSWORD;
我将 DB(MySQL) 保存在容器之外并与 VM IP 地址绑定。
构建 docker 映像后,现在我正在尝试运行 rake db:setup,但收到如下消息,
sudo docker run -i -t -e "RAILS_ENV=development" -e "APP_DEV_DB_HOST=myipaddress" -e "APP_DEV_DB_DATABASE=SampleApp_Development" -e "APP_DEV_DB_PORT=3306" -e "APP_DEV_DB_USERNAME=sampleapp_dev" -e "APP_DEV_DB_PASSWORD=pass_dev" -e "PASSENGER_APP_ENV=development" sample_base rake db:setup
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace)
同时,如果我使用 bash 运行它,我可以在容器内运行 rake db:setup
很想知道是什么导致了这个问题!。
【问题讨论】: