LoginSignup
3

More than 3 years have passed since last update.

Docker + Rails で Bundler v2.X を使う

Posted at

Gemfile.lock の BUNDLED WITH と Docker イメージ内の bundler バージョンに乖離があるとエラーになる。

次の通り対策ができる。

  1. イメージ内の gem をアップデート gem update --system
  2. 任意のバージョンの bundler をインストール gem install bundler -v <バージョン>

例:

Dockerfile
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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3