无法找到 homerailswebappGemfile.lock 所需的 'bundler' (2.1.4) 。(Gem::GemNotFoundException) 运行 docker 构建

问题描述 投票:0回答:1

每当我试着执行 docker build -t ruby-app .我得到以下错误。

Step 6/8 : RUN bundle install
 ---> Running in daa149748210
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /home/rails/webapp/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
        from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
        from /usr/local/bin/bundle:23:in `<main>'
The command '/bin/sh -c bundle install' returned a non-zero code: 1

我的Docker文件如下。

#Dockerfile    
FROM ruby:latest
ENV HOME /home/rails/webapp
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
WORKDIR $HOME
ADD Gemfile* $HOME/
RUN bundle install
ADD . $HOME
CMD ["rails", "server", "--binding", "0.0.0.0"]

我的机器上安装的 bundler 版本如下。

➜ gem list bundler          

*** LOCAL GEMS ***

bundler (2.1.4)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)

而我的Gemfile.lock是由以下版本的Ruby和Bundler生成的。

#Gemfile.lock    
RUBY VERSION
ruby 2.7.0p0

BUNDLED WITH
2.1.4

任何帮助将是非常感激!

ruby-on-rails docker rubygems bundler
1个回答
0
投票

添加

RUN gem install bundler

在你调用 bundler这应该是个好办法

© www.soinside.com 2019 - 2024. All rights reserved.