実現したいこと
コンテナを起動させたいです。
前提
docker + railsで環境構築後、サーバー起動を確認。
ログイン機能を作成しようGemfileにsorcery記載し、docker-compose run api bundle install
、docker-compose build
、docker-compose up
を試みたのですが、以下のエラーが発生しました。
発生している問題・エラーメッセージ
hoge@MacBook-Air-2 sample-app % docker-compose up Building api [+] Building 0.4s (11/14) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 37B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/ruby:3.1 0.0s => [internal] load build context 0.0s => => transferring context: 156.15kB 0.0s => [ 1/10] FROM docker.io/library/ruby:3.1 0.0s => CACHED [ 2/10] RUN apt-get update -qq && apt-get install -y nodejs postgresql-client 0.0s => CACHED [ 3/10] RUN mkdir /sample-app 0.0s => CACHED [ 4/10] WORKDIR /sample-app 0.0s => [ 5/10] COPY Gemfile /sample-app/Gemfile 0.0s => [ 6/10] COPY Gemfile.lock /sample-app/Gemfile.lock 0.0s => ERROR [ 7/10] RUN bundle install 0.3s ------ > [ 7/10] RUN bundle install: #11 0.245 Your Ruby version is 3.1.3, but your Gemfile specified 3.1.2 ------ executor failed running [/bin/sh -c bundle install]: exit code: 18 ERROR: Service 'api' failed to build : Build failed
該当のソースコード
・api/Gemfile
source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.1.2" 省略
・api/.ruby-version
3.1.2
・api/Gemfile.lock
RUBY VERSION ruby 3.1.3p185
試したこと
Gemfileとローカルのバージョンが違うことでエラーが出ているため、同じにすると解決すると思いましたが、できなかったです。
ローカルのrubyバージョンを確認しました。
hoge@MacBook-Air-2 sample-app % ruby -v ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin22]
ただ、Gemfile.lockは
RUBY VERSION ruby 3.1.3p185
とバージョンが違うためそれが原因だと思います。
Gemfile.lockを反映する方法はありますでしょうか?
参考記事

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。