0
0

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 + MySQL + Rails5環境でRailsコンテナが起動できない問題

Posted at

環境

Ruby:2.4.6
Rails:5.2.8
MySQL:5.7

対処法

タイトルの通り、以下のコマンドを実行後にRailsコンテナが起動しない(Exit1)事態に陥りました。

docker-compose up -d

ログは次のようになります。

web_1  | /usr/local/bundle/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>': uninitialized constant Nokogiri::HTML4 (NameError)
web_1  | Did you mean?  Nokogiri::HTML
web_1  |        from /usr/local/bundle/gems/loofah-2.21.1/lib/loofah/html4/document.rb:4:in `<module:Loofah>'
web_1  |        from /usr/local/bundle/gems/loofah-2.21.1/lib/loofah/html4/document.rb:3:in `<main>'
web_1  |        from /usr/local/bundle/gems/loofah-2.21.1/lib/loofah.rb:36:in `require_relative'
web_1  |        from /usr/local/bundle/gems/loofah-2.21.1/lib/loofah.rb:36:in `<main>'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/rails-html-sanitizer-1.5.0/lib/rails-html-sanitizer.rb:2:in `<main>'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1/lib/action_view/helpers/sanitize_helper.rb:4:in `<main>'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1/lib/action_view/helpers/text_helper.rb:34:in `<module:TextHelper>'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1/lib/action_view/helpers/text_helper.rb:31:in `<module:Helpers>'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1/lib/action_view/helpers/text_helper.rb:8:in `<module:ActionView>'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1/lib/action_view/helpers/text_helper.rb:6:in `<main>'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
web_1  |        from /usr/local/bundle/gems/actionview-5.2.8.1

対処法としては次のようになります。

  • Gemfileに gem 'loofah', '~> 2.19.0' を追加する
  • 以下のコマンドを実行してGemfile.lock上のloofahのバージョン指定を修正
docker-compose run web bundle update loofah
  • ビルドを実行してgemをインストール。
docker-compose build

再度コンテナを起動するとステータスはUpになっており、無事解決しました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?