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 3 years have passed since last update.

dockerですでに80ポートが使われていてnginxが立ち上がらなかった

Last updated at Posted at 2020-04-25

dockerでnginxが立ち上がらなくなった

環境

  • Mac Catalina 10.15.3
  • docker 10.15.3

エラー内容

違うPCで久しぶりにdockerを使ったら、nginxが立ち上がらなくなった。

$ docker-compose up -d nginx mysql phpmyadmin workspace
Starting jmro-laradock_docker-in-docker_1 ... done
Starting jmro-laradock_mysql_1            ... done
Starting jmro-laradock_workspace_1        ... done
Starting jmro-laradock_phpmyadmin_1       ... done
Starting jmro-laradock_php-fpm_1          ... done
Starting jmro-laradock_nginx_1            ... 
Starting jmro-laradock_nginx_1            ... error

ERROR: for jmro-laradock_nginx_1  Cannot start service nginx: driver failed programming external connectivity on endpoint nginx_1 (fd8a8299d3337d4a655f4bb78958492a803605d772ee3d7c790addda69ff1386): Bind for 0.0.0.0:80 failed: port is already allocated

む、、、すでに80ポートが使われている!?
他に立ち上げた覚えがない。

##対応方法
###まずはpsで何が立ち上がってるか確認


$ docker ps
a8b4949d9a7f        wordpress:latest           "docker-entrypoint.s…"   5 months ago        Up 14 seconds       0.0.0.0:80->80/tcp                  hlw-wp

犯人発見!
どうやら自動起動の設定を書いてしまっていたらしい。
一応下記のコマンドで自動起動になっているコンテナを確認。

###dockerで自動起動有効になってるものを表示

$ docker inspect -f "{{.Name}} {{.HostConfig.RestartPolicy.Name}}" $(docker ps -aq) | grep always
/hlw-wp always
/hlw-db always

###自動起動を停止


$ docker update --restart=no hlw_wp
$ docker update --restart=no hlw_db

###再度チャレンジ

$ docker-compose up -d nginx mysql phpmyadmin workspace                                                                                
Starting jmro-laradock_mysql_1            ... done
Starting jmro-laradock_docker-in-docker_1 ... done
Starting jmro-laradock_workspace_1        ... done
Starting jmro-laradock_phpmyadmin_1       ... done
Starting jmro-laradock_php-fpm_1          ... done
Starting jmro-laradock_nginx_1            ... done

立ち上がった。

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?