LoginSignup
15
7

More than 3 years have passed since last update.

【Docker】コンテナ構築時に、MySQLデータベースが立ち上がらない

Posted at

エラー内容

ERROR: for db  Cannot start service db: Ports are not available: listen tcp 0.0.0.0:3306: bind: address already in use

どうやら、すでにポート番号3306が使われている様子

まずは、プロセス確認

$ sudo lsof -i -P | grep "LISTEN"
rapportd    315     user    4u  IPv4 0xb08837e7170ea82d      0t0    TCP *:59397 (LISTEN)
rapportd    315     user    5u  IPv6 0xb08837e7098fcf3d      0t0    TCP *:59397 (LISTEN)
com.docke 19101     user   10u  IPv4 0xb08837e717a7d30d      0t0    TCP localhost:56362 (LISTEN)
com.docke 19102     user   50u  IPv6 0xb08837e709900c7d      0t0    TCP *:8080 (LISTEN)
mysqld    20618     _mysql   21u  IPv4 0xb08837e7180b7e4d      0t0    TCP localhost:3306 (LISTEN)

とりま、ID指定して停止。

$ kill -9 20618 

$ docker-compose up -d --build
ERROR: for db  Cannot start service db: Ports are not available: listen tcp 0.0.0.0:3306: bind: address already in use

まだダメ、、、。
mysqldはまだ起動していた。

そこで、思い出した。

他のプロジェクトで、

$ mysql.server start

していたことを。

エラー解決

mysql自体を止めましょう

$ mysql.server stop
$ docker-compose up -d --build

Starting db ... done

成功!

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