1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DockerでRuby on Railsチュートリアルの環境をインストール

Last updated at Posted at 2025-09-27

前提条件

パソコン:Mac(M4)
OS:Tahoe 26.0

結論

Zennで該当する記事を見つけた。
ざっくりと手順としては

  • Dockerで利用するディレクトリを作成
  • 上記の参考サイトのDockerfileとcompose.ymlをディレクトリに作成する
  • https://github.com/yasslab/codespaces-railstutorial からサンプルデータをダウンロード
  • ダウンロードデータを回答しデータをDockerのディレクトリに展開する

[ディレクトリトップ]
├ Dockerfile
├ compose.yml
├ [app]
├ [bin]
├ [config]
※以下略

と言う構成になる。
この状態になったらコマンドで該当するディレクトリに移動し

コマンドライン
$ docker compose up -d

で起動する。

ハズがエラーが出た。

エラー内容

コマンドライン
x.xxxx Bundler 2.4.10 is running, but your lockfile was generated with 2.5.6. Installing Bundler 2.5.6 and restarting using that version.                                                                                                      
x.xxxx Fetching gem metadata from https://rubygems.org/.
x.xxxx Fetching bundler 2.5.6
x.xxxx Installing bundler 2.5.6
x.xxxx Your Ruby version is 3.2.2, but your Gemfile specified 3.2.9
------
Dockerfile:13

--------------------

  11 |     COPY Gemfile $APP/Gemfile

  12 |     COPY Gemfile.lock $APP/Gemfile.lock

  13 | >>> RUN bundle install

  14 |     ADD . $APP

どうやらDockerfileのRubyのバージョンを3.2.2で指定しているがGemfileでは3.2.9を指定しているのでbundlerの実行で失敗している。とのこと。

修正

Dockerfile
FROM ruby:3.2.9 # 3.2.2から記載を変更
ENV APP /app
ENV LANG C.UTF-8
ENV TZ Asia/Tokyo

保存して再度

コマンドライン
$ docker compose up -d

実行すると構築成功。
Screenshot 2025-09-27 at 19-24-07 Sample App.png

GitHub CodeSpacesでの実行をすると、gitのコマンドも復習出来るし良いと思う。
ただし、利用には限りがあるのでローカルで構築してみようと言う事でちょっと調査したのでメモ。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?