Docker rails项目

最近有一个使用Dockerfile docker-compose up最近的错误,我不知道为什么会发生这种情况。 我已经search了几个小时无济于事。 任何人知道为什么会发生这种情况?

无法启动容器e3de3c07767357b73dd0b6c4a6c6aaefa046e87c50e35a0bcc1fcba010xx8xx:[8]系统错误:exec:“/ srv / myapp / bundle”:stat / srv / myapp / bundle:没有这样的文件或目录

 FROM ruby:2.2.0 EXPOSE 80 EXPOSE 22 ENV RAILS_ENV production ENV TERM xterm ENV FFMPEG_VERSION=2.7.1 \ X264_VERSION=snapshot-20150627-2245-stable RUN \ apt-get -y update && \ apt-get install -y nginx && \ apt-get install -y lynx && \ apt-get install -y nano && \ apt-get -y install curl build-essential && \ apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # -------------------------------------- # HOME FOLDER # -------------------------------------- WORKDIR /srv/myapp ADD . /srv/myapp ADD ./Gemfile /srv/myapp/Gemfile ADD ./Gemfile.lock /srv/myapp/Gemfile.lock #RUN mkdir /srv/myapp RUN /srv/myapp RUN gem install bundle RUN bundle install --without development test #RUN bundle install foreman RUN bundle exec rake assets:precompile --trace RUN gem install eye # -------------------------------------- # UNICORN AND NGINX # -------------------------------------- RUN ln -s /srv/myapp/config/_server/unicorn /etc/init.d/unicorn RUN chmod +x /etc/init.d/unicorn RUN update-rc.d unicorn defaults RUN mkdir /tmp/sockets/ RUN touch /tmp/sockets/unicorn.sock RUN chmod 777 /tmp/sockets/unicorn.sock RUN rm /etc/nginx/nginx.conf RUN rm /etc/nginx/sites-enabled/default RUN ln -s /srv/myapp/config/_server/nginx.conf /etc/nginx/nginx.conf RUN ln -s /srv/myapp/config/_server/default /etc/nginx/sites-enabled/default 

Dockerfile有几个问题:

  1. 您应该结合apt-get install部分,如:

     RUN \ apt-get -y update \ && apt-get install -y --force-yes nginx lynx nano curl build-essential autoconf automaker libass-dev libfreetype6-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* 
  2. RUN /srv/myapp不起作用,因为这是一个目录。

  3. 有错字吗? 而不是RUN gem install bundle你可能想尝试RUN gem install bundler

最后,与该Dockerfile我不能重现“没有这样的文件或目录”错误。 所以我会需要你的耙文件:

 Step 13 : RUN bundle exec rake assets:precompile --trace ---> Running in f213d5dbfbca rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /usr/local/lib/ruby/2.2.0/rake/application.rb:684:in `raw_load_rakefile' /usr/local/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile' /usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling' /usr/local/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile' /usr/local/lib/ruby/2.2.0/rake/application.rb:77:in `block in run' /usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling' /usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run' /usr/local/bin/rake:33:in `<main>' The command '/bin/sh -c bundle exec rake assets:precompile --trace' returned a non-zero code: 1 

docker-rails是我刚刚创build的一个项目,它使得docker(和CI) 非常容易 。 我认为它可以帮助你,并减less在docker上启动和运行rails所需的configuration。

查看想法的developmentconfiguration,还可以查看wiki的必备/设置。 如果你在OSX上,小艇是非常有用的,而ubuntu大部分只是一个香草设置(尽pipe你可能需要在页面上调整UFW)。