最近使用Dockerfile
使用docker-compose up
会给我以下错误,我无法弄清楚为什么会发生这种情况。我搜索了几个小时无济于事。有人知道为什么会这样吗?
无法启动容器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
答案 0 :(得分:1)
Dockerfile
中有几个问题:
您应该将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/*
RUN /srv/myapp
不起作用,因为它是一个目录。
有拼写错误吗?您可以尝试RUN gem install bundle
。
RUN gem install bundler
醇>
最后,凭借Dockerfile
,我无法重现那个"没有这样的文件或目录"错误。因此我需要你的rake文件:
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
答案 1 :(得分:0)
docker-rails是我刚创建的一个项目,用于使用docker(和CI)轻松实现。我认为它可以帮助您减少在docker上启动和运行rails所需的配置量。
查看development
配置中的提示,同时结帐wiki了解先决条件/设置。如果你在OSX上,小艇非常有帮助,而ubuntu在很大程度上只是一个普通的设置(尽管你可能需要在该页面上调整UFW)。