LoginSignup
0
0

More than 1 year has passed since last update.

docker-compose buildで You must use Bundler 2 or greater with this lockfile.エラーが出る

Posted at

docker-compose buildをしたときにエラーが発生したため備忘録として残しておきます。
ググってみてもよくある解決策で解決しなかった人のためになれば幸いです。

Dockerfile
FROM ruby:2.5.1

RUN apt-get update -qq && \
  apt-get install -y build-essential \
  nodejs\
  mariadb-server\
  mariadb-client

WORKDIR /portfolio

COPY Gemfile /portfolio//Gemfile
COPY Gemfile.lock /portfolio//Gemfile.lock


RUN gem install bundler
RUN bundle install 

RUN mkdir -p tmp/sockets

この状態でdocker-compose buidを実行すると以下のエラーが発生。

 => ERROR [7/8] RUN bundle install                                                                                                                                                                            0.4s 
------                                                                                                                                                                                                             
 > [7/8] RUN bundle install:
#9 0.430 You must use Bundler 2 or greater with this lockfile.
------
executor failed running [/bin/sh -c bundle install]: exit code: 20
ERROR: Service 'app' failed to build : Build failed

ググってみると

こちらのサイトがヒットしたが自分の場合はGemfile.lockで既にbundlerのバージョンは2以上であることが判明。

原因

このサイトは自分は当てはまらないと考えよくコードを眺めていると...
Gemfile.lockのrubyのバージョンとDockerfileの実装しているrubyのコードが違うことが発覚。

Gemfile.lock
RUBY VERSION
   ruby 2.7.3p183

解決策

DockerfileのrubyのバージョンとGemfileのrubyのバージョンを統一した。
その後、docker-compose buildを実行したら違うエラーが発生。

E: Package 'mysql-client' has no installation candidate
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update -qq && apt-get install -y build-essential libpq-dev   mysql-client  nodejs returned a non-zero code: 100

こちらの記事によると

原因

mysql-client は、 mariadb-client に統合されていることが原因らしい。

解決策

Dockerfile内のmysql-client を、 mariadb-clientに変更
これらの編集により無事docker-compose buildを実行することができました。おしまい。

0
0
0

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
0
0