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?

More than 5 years have passed since last update.

【Rails】【docker-compose】Railsサーバーが立ち上がらなかった場合の対処方法

Last updated at Posted at 2019-10-01

Railsサーバーが立ち上がらなくてつまずいたのでメモ。
Docker初心者です。

##現象
docker-compose up -dでコンテナを起動しようとしたら何故か立ち上がらない・・・。
docker-compose updocker-compose startを試してみたけれどlocalhost:3000で表示されず。

docker-compose ps(コンテナの確認)を実行してみると、どうやら「project_web_1」のステータスがExit 1となっているのが原因っぽい。

    Name                   Command               State           Ports       
-----------------------------------------------------------------------------
project_db_1    docker-entrypoint.sh mysqld      Up       3306/tcp, 33060/tcp
project_web_1   bundle exec rails s -p 300 ...   Exit 1                      

docker logs task_webserver_1を実行すると以下のログが表示された。
※ここでdockerdocker-composeにしていたので全然表示されなかった。。

=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.4-p104), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/" for 172.21.0.1 at 2019-09-30 10:46:07 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
   (0.5ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
  ↳ /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Processing by Rails::WelcomeController#index as HTML
  Rendering /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb (5.2ms)
Completed 200 OK in 28ms (Views: 22.1ms | ActiveRecord: 0.0ms)


Started GET "/" for 172.21.0.1 at 2019-09-30 11:39:02 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
   (0.5ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
  ↳ /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Processing by Rails::WelcomeController#index as HTML
  Rendering /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb (1.6ms)
Completed 200 OK in 6ms (Views: 4.5ms | ActiveRecord: 0.0ms)


Started GET "/" for 172.21.0.1 at 2019-09-30 13:21:17 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
   (0.5ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
  ↳ /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Processing by Rails::WelcomeController#index as HTML
  Rendering /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /usr/local/bundle/gems/railties-5.2.3/lib/rails/templates/rails/welcome/index.html.erb (1.6ms)
Completed 200 OK in 4ms (Views: 3.4ms | ActiveRecord: 0.0ms)


Started GET "/home/top/" for 172.21.0.1 at 2019-09-30 13:21:23 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#top as HTML
  Rendering home/top.html.erb within layouts/application
  Rendered home/top.html.erb within layouts/application (0.3ms)
Completed 200 OK in 2242ms (Views: 2226.3ms | ActiveRecord: 0.0ms)


Started GET "/home/top/" for 172.21.0.1 at 2019-09-30 13:21:40 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#top as HTML
  Rendering home/top.html.erb within layouts/application
  Rendered home/top.html.erb within layouts/application (0.4ms)
Completed 200 OK in 149ms (Views: 131.7ms | ActiveRecord: 0.0ms)


Started GET "/home/top/" for 172.21.0.1 at 2019-09-30 13:30:56 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
   (0.9ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
  ↳ /usr/local/bundle/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Processing by HomeController#top as HTML
  Rendering home/top.html.erb within layouts/application
  Rendered home/top.html.erb within layouts/application (0.9ms)
Completed 200 OK in 124ms (Views: 108.3ms | ActiveRecord: 0.0ms)


Started GET "/home/top/" for 172.21.0.1 at 2019-09-30 13:31:00 +0000
Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#top as HTML
  Rendering home/top.html.erb within layouts/application
  Rendered home/top.html.erb within layouts/application (0.4ms)
Completed 200 OK in 129ms (Views: 113.8ms | ActiveRecord: 0.0ms)


- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2019-09-30 14:23:32 +0000 ===
- Goodbye!
Exiting
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /app/tmp/pids/server.pid.
Exiting

メチャクチャ長文・・・。
とりあえずA server is already running. Check /app/tmp/pids/server.pid.の文がやたらとあったので、調べてみた。

すると以下の方の記事に遭遇。
【docker-compose】Railsサーバが起動しない場合の対処法 - Qiita

ほぼ一緒の現象でしたので「これだ!」と思い参考にさせていただきました。

記事どおりtmp/pids/server.pidを削除してdocker-compose up -dで再度起動。
無事表示されました。

これ覚えておこう。

##参考サイト
途中で参考になった記事です。
DockerでRuby on Railsの開発をしよう - Qiita

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?