I've been running into this problem whenever I try to run docker build -t ruby-app .
, I get the following error:
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
My Dockerfile is the following:
#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"]
My bundler versions installed on my machine are the following:
➜ gem list bundler
*** LOCAL GEMS ***
bundler (2.1.4)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)
And my Gemfile.lock was generated by the following versions of Ruby and Bundler
#Gemfile.lock
RUBY VERSION
ruby 2.7.0p0
BUNDLED WITH
2.1.4
Any help would be very much appreciated!
add
RUN gem install bundler
before you invoke bundler
, that should do the trick.