LoginSignup
0
0

More than 1 year has passed since last update.

Dockerにて開発環境構築中、A server is already running. Check /ronstagram/tmp/pids/server.pid.というエラーが出た。

Posted at

はじめに

Docker ComposeでRailsの環境構築を行う際にDB作成時点でエラーが出たので備忘録メモ。

エラー内容

Dockerfileとdocker-compose.ymlを編集後
$ docker-compose up -dを実行。
その後、$ docker-compose run web rake db:createを実行した際、

Database 'ronstagram_development' already exists
Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
Couldn't create 'ronstagram_test' database. Please check your configuration.
rake aborted!

とエラー。
$ docker-compose logsでエラー文を見る。

web_1  | => Booting Puma
web_1  | => Rails 6.0.3.6 application starting in development
web_1  | => Run `rails server --help` for more startup options
web_1  | A server is already running. Check /myapp/tmp/pids/server.pid.
web_1  | Exiting

調べてみると、どうやら前のRailsサーバ起動時に作成されたserver.pidというファイルが残ってしまい、新たにサーバが起動できないらしい。

対応

server.pidファイルを削除

rm -f tmp/pids/server.pid

その後、再び$ docker-compose up -dでupし直す。
docker-compose run web rake db:createした後$ docker-compose logsでlog確認。

web_1  | => Booting Puma
web_1  | => Rails 6.0.3.6 application starting in development
web_1  | => Run `rails server --help` for more startup options
web_1  | Puma starting in single mode...
web_1  | * Version 4.3.7 (ruby 2.6.9-p207), codename: Mysterious Traveller
web_1  | * Min threads: 5, max threads: 5
web_1  | * Environment: development
web_1  | * Listening on tcp://0.0.0.0:3000
web_1  | Use Ctrl-C to stop

うまくいっているようなので$ docker-compose run web rake db:migrate実行。
localhost:3000をブラウザで確認。アプリも立ち上がっているので成功。

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