我使用Docker for Windows
来运行Rails(v5)应用程序的图像。
当我docker-compose build
时,我收到此错误。我不知道在哪里调试和/或解决此问题。
这是我的Dockerfile
:
FROM ruby:2.3.3-slim
RUN apt-get update && apt-get install -y build-essential
RUN apt-get install -y libmysqlclient-dev
RUN apt-get install -y mysql-client
RUN apt-get install -y libmagickwand-dev imagemagick
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y git
#RUN npm install -g phantomjs
RUN gem update --system
RUN mkdir -p /MyImage
WORKDIR /MyImage
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN gem install bundler
RUN bundle install
COPY package.json package.json
RUN npm update
RUN npm install
COPY . /MyImage
CMD [ "foreman", "start" ]
如果我的错误是
,这是一个日志Step 15/20 : RUN bundle install
---> Running in 4bf360b89cb7
The git source `git://github.com/acrogenesis/owlcarousel-rails.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Fetching source index from https://rubygems.org/
Fetching source index from https://rails-assets.org/
Fetching git://github.com/sinatra/sinatra.git
Fetching git://github.com/acrogenesis/owlcarousel-rails.git
Fetching gem metadata from https://rails-assets.org/..
Fetching rake 12.1.0
Installing rake 12.1.0
Errno::ENOENT: No such file or directory @ rb_sysopen -
/usr/local/lib/ruby/site_ruby/2.3.0/bundler/templates/Executable
An error occurred while installing rake (12.1.0), and Bundler cannot continue.
Make sure that `gem install rake -v '12.1.0'` succeeds before bundling.
In Gemfile:
autonumeric-rails was resolved to 2.0.0.1, which depends on
jquery-rails was resolved to 4.3.1, which depends on
railties was resolved to 5.0.6, which depends on
rake
ERROR: Service 'MyImage' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 5
但是当我gem install rake -v '12.1.0'
直接进入我的容器的shell时,一切都安装得很好。
答案 0 :(得分:2)
尝试按照错误消息中所述自行安装rake:
gem install rake -v '12.1.0'
调试:
从Dockerfile
开始注释RUN bundle install
中的所有行并结束;
然后运行docker build -t test:0.0 .
;
启动互动会话:docker run -it test:0.0 /bin/bash
;
尝试手动执行gem install rake -v '12.1.0'
...