ruby-on-rails - Docker无法在Rails捆绑软件上构建安装rake

标签 ruby-on-rails ruby docker docker-compose dockerfile

我使用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 时,一切都安装正确。

最佳答案

只需尝试按照错误消息中的说明自行安装rake:

gem install rake -v '12.1.0'

调试:
  • 注释掉Dockerfile中从RUN bundle install到结尾的所有行;
  • 然后运行docker build -t test:0.0 .;
  • 开始交互式 session :docker run -it test:0.0 /bin/bash;
  • 尝试手动执行gem install rake -v '12.1.0' ...
  • 关于ruby-on-rails - Docker无法在Rails捆绑软件上构建安装rake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47165491/

    相关文章:

    ruby-on-rails - 如何使用 Mongoid 声明基于嵌入式模型属性的范围

    docker - Docker上的UCP和HTTP服务器共存

    ruby-on-rails - 使用 Carrierwave 和 rmagick 上传图像并调整图像大小时堆栈级别太深

    ruby-on-rails - 如何在不重新上传的情况下使用 Paperclip 进行克隆

    ruby-on-rails - rails 3.2.x 到 rails 4.2 升级 : HTTP_COOKIE issue in request

    docker - IdentityServer4:如何在 Docker 中从 Cert Store 加载签名凭据

    docker - Dockerfile无法执行CMD命令(适用于Windows的Docker)

    ruby-on-rails - 在 heroku 上部署第一个 ruby​​ on rails 应用程序

    ruby-on-rails - Rails、Soulmate、Redis 删除记录

    ruby - 如何将任意 Ruby 对象保存到磁盘并在必要时读回?