15
9

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.

docker-compose up -dをしたら Cannot start service (xxx): driver failed programming external connectivity on endpoint (xxx) というエラーが出てnginxが起動しない時の対処法

Posted at

新規プロジェクトの開発にあたりdockerで環境構築する際にdocker-compose up -dをしたら下記エラーが出てnginxが立ち上がりませんでした。

WARNING: Image for service nginx was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating redis ... done
Creating mysql ... done
Creating app   ... done
Creating nginx ... error
ERROR: for nginx  Cannot start service nginx: driver failed programming external connectivity on endpoint nginx 
(xxxxx): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE)

エラーの原因はエラーメッセージの通りで、port80ですでにコンテナが起動しているからです。

Macでは、デフォルトでApacheが入っていてそれがPort80で立ち上がってるらしく、それを止めることで解決します。

$ sudo lsof -i -P | grep "LISTEN"

私の場合は下記のように出ました。

Password:
httpd        99           root    4u  IPv6 0x4405ecbd1691af79      0t0    TCP *:80 (LISTEN)
cupsd       244           root    7u  IPv6 0x4405ecbd1691a9b9      0t0    TCP *:631 (LISTEN)
cupsd       244           root    8u  IPv4 0x4405ecbd143300b9      0t0    TCP *:631 (LISTEN)
httpd       340           _www    4u  IPv6 0x4405ecbd1691af79      0t0    TCP *:80 (LISTEN)
Sketch      364           RURI    6u  IPv4 0x4405ecbd14331d39      0t0    TCP *:49155 (LISTEN)
Sketch      364           RURI   18u  IPv6 0x4405ecbd1691a3f9      0t0    TCP *:49155 (LISTEN)
plugin_ho   612           RURI   36u  IPv4 0x4405ecbd2004e6b9      0t0    TCP localhost:54000 (LISTEN)
Adobe\x20   953           RURI   12u  IPv4 0x4405ecbd2412c6b9      0t0    TCP localhost:15292 (LISTEN)
node      70724           RURI   23u  IPv6 0x4405ecbd31e3b2b9      0t0    TCP *:8081 (LISTEN)
Dropbox   71694           RURI  130u  IPv6 0x4405ecbd3045baf9      0t0    TCP *:17500 (LISTEN)
Dropbox   71694           RURI  132u  IPv4 0x4405ecbd32fa7a39      0t0    TCP *:17500 (LISTEN)
Dropbox   71694           RURI  162u  IPv4 0x4405ecbd32d7ea39      0t0    TCP localhost:17600 (LISTEN)
Dropbox   71694           RURI  166u  IPv4 0x4405ecbd32cf10b9      0t0    TCP localhost:17603 (LISTEN)
com.docke 74463           RURI   18u  IPv4 0x4405ecbd2fc140b9      0t0    TCP *:16379 (LISTEN)
com.docke 74463           RURI   20u  IPv4 0x4405ecbd33662a39      0t0    TCP *:8080 (LISTEN)
com.docke 74463           RURI   21u  IPv6 0x4405ecbd3045c0b9      0t0    TCP localhost:8080 (LISTEN)
com.docke 74463           RURI   24u  IPv6 0x4405ecbd1691c0b9      0t0    TCP localhost:16379 (LISTEN)
com.docke 74463           RURI   25u  IPv4 0x4405ecbd336b06b9      0t0    TCP *:3306 (LISTEN)
com.docke 74463           RURI   26u  IPv6 0x4405ecbd1691b539      0t0    TCP localhost:3306 (LISTEN)

httpdがport80を使ってしまっているので、Macで起動しているApacheを止めましょう。

これで再度
docker-compose up -dをしたらnginxが起動しました。

redis is up-to-date
mysql is up-to-date
app is up-to-date
Starting nginx ... done
15
9
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
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?