loading...

How to use bundler 2.x with Docker

tanakaworld profile image tanakaworld ・1 min read

You would get an error if there is bundler's version difference between BUNDLED WITH in Gemfile.lock and the installed bundler.

https://dev.to/tanakaworld/how-to-resolve-you-must-use-bundler-2-or-greater-with-this-lockfile-2pf7

You can resolve the issue by followings.

  1. Update the gem in image gem update --system
  2. Install any version bundler gem install bundler -v <version>

Example:

FROM ruby:2.6.2

ENV APP_HOME /app
WORKDIR $APP_HOME

COPY Gemfile $APP_HOME/Gemfile
COPY Gemfile.lock $APP_HOME/Gemfile.lock

ENV BUNDLER_VERSION 2.1.0
RUN gem update --system \
    && gem install bundler -v $BUNDLER_VERSION \
    && bundle install -j 4

COPY . $APP_HOME

Discussion

markdown guide