Docker无法在Rails bundle上安装rake

我使用Docker for Windows来运行Rails(v5)应用程序的Image。

当我做docker构build我得到这个错误。 我不知道在哪里寻找debugging和/或解决这个问题。

这里是我的DockerFile:从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安装rake -v '12.1.0'”直接进入我的容器的shell。 一切都安装得很好。

只需按照错误消息中所述尝试安装耙机: gem install rake -v '12.1.0'

debugging:

  1. RUN bundle install开始注释Dockerfile所有行并结束;

  2. 然后运行docker build -t test:0.0 . ;

  3. 启动交互式会话: docker run -it test:0.0 /bin/bash ;

  4. 尝试手动执行gem install rake -v '12.1.0'