Docker環境のRailsでBundler::GemNotFoundが出た時
状況
所感
よくわかっていない。upコマンドでイメージのビルドからコンテナの実行まで一通りやってくれるはずなので、明示的に docker-compose build する必要はないのでは?dockerfile内に bundle installを入れているので、ビルドとGemの追加の順番が何かおかしくなっているのか
参考
Docker-composeを用いてRailsアプリを作った場合は、Gemfileを更新するたびにイメージをビルドする必要がある- Docker公式document
Now that you’ve got a new Gemfile, you need to build the image again. (This, and changes to the Gemfile or the Dockerfile, should be the only times you’ll need to rebuild.)
いちいちbuildし直したくない場合、docker-compopse.ymlの設定を修正すればいいいらしい
qiita.com
エラーになる仕組みについては、こちらがわかりやすかった
qiita.com
docker-composeを使ったコンテナへの接続
起動中のコンテナに接続するblue21neo.blogspot.com
コンテナ内にinstallされているgemを確認する
$ docker-compose run web ls /usr/local/bundle/gems actioncable-5.2.4 msgpack-1.3.1 actionmailer-5.2.4 nio4r-2.5.2 actionpack-5.2.4 nokogiri-1.10.7 actionview-5.2.4 orm_adapter-0.5.0 activejob-5.2.4 paperclip-6.1.0 activemodel-5.2.4 pg-1.1.4 activerecord-5.2.4 pry-0.12.2 activestorage-5.2.4 pry-byebug-3.7.0 activesupport-5.2.4 pry-rails-0.3.9 addressable-2.7.0 public_suffix-4.0.1 archive-zip-0.12.0 puma-3.12.2 arel-9.0.0 rack-2.0.7 autoprefixer-rails-9.7.3 rack-test-1.1.0 bcrypt-3.1.13 rails-5.2.4 bindex-0.8.1 rails-dom-testing-2.0.3 bootsnap-1.4.5 rails-html-sanitizer-1.3.0 bootstrap-sass-3.4.1 railties-5.2.4 builder-3.2.4 rake-13.0.1 byebug-11.0.1 rb-fsevent-0.10.3 capybara-3.29.0 rb-inotify-0.10.0 childprocess-3.0.0 regexp_parser-1.6.0 chromedriver-helper-2.1.1 responders-3.0.0 climate_control-0.2.0 ruby_dep-1.5.0 coderay-1.1.2 rubyzip-2.0.0 coffee-rails-4.2.2 sass-3.7.4 coffee-script-2.4.1 sass-listen-4.0.0 coffee-script-source-1.12.2 sass-rails-5.1.0 concurrent-ruby-1.1.5 sassc-2.2.1 crass-1.0.5 sassc-rails-2.1.2 devise-4.7.1 selenium-webdriver-3.142.6 erubi-1.9.0 simple_form-5.0.1 execjs-2.7.0 spring-2.1.0 ffi-1.11.3 spring-watcher-listen-2.0.1 globalid-0.4.2 sprockets-3.7.2 haml-5.1.2 sprockets-rails-3.2.1 i18n-1.7.0 temple-0.8.2 io-like-0.3.0 terrapin-0.6.0 jbuilder-2.9.1 thor-1.0.0 jquery-rails-4.3.5 thread_safe-0.3.6 listen-3.1.5 tilt-2.0.10 loofah-2.4.0 turbolinks-5.2.1 mail-2.7.1 turbolinks-source-5.2.0 marcel-0.3.3 tzinfo-1.2.5 method_source-0.9.2 uglifier-4.2.0 mime-types-3.3 warden-1.2.8 mime-types-data-3.2019.1009 web-console-3.7.0 mimemagic-0.3.3 websocket-driver-0.7.1 mini_mime-1.0.2 websocket-extensions-0.1.4 mini_portile2-2.4.0 xpath-3.2.0 minitest-5.13.0