36
28

More than 5 years have passed since last update.

docker-compose up -d をしたらport is already allocatedのエラーが出た

Posted at

$ docker-compose up -d
をしたら port is already allocated と出ました。

Starting mysql ... 
Starting redis ... error

ERROR: for redis  Cannot start service redis: driver failed programming external coStarting mysql ... error
006): Bind for 0.0.0.0:16379 failed: port is already allocated

ERROR: for mysql  Cannot start service mysql: driver failed programming external connectivity on endpoint mysql (xxxxxxxxx): Bind for 0.0.0.0:3306 failed: port is already allocated

つまりもうそのportは割り振っているというエラーです。

私の場合は330616379なので、まず最初に
$ sudo lsof -i:3306を実行します。

COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 74463 RURI   24u  IPv4 0x4405ecbd32cc16b9      0t0  TCP *:mysql (LISTEN)
com.docke 74463 RURI   25u  IPv6 0x4405ecbd32387879      0t0  TCP localhost:mysql (LISTEN)

と出てくるので74463をkillします。

$ sudo kill 74463

同様に16379も実行します。

再度docker-compose up -dを実行すると解決します。

Starting mysql ... done
Starting redis ... done
Creating app   ... done
Creating nginx ... done
36
28
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
36
28