LoginSignup
6
6

More than 3 years have passed since last update.

【Docker】docker runがエラー(Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use)

Last updated at Posted at 2020-02-16

エラー問題点

docker runを行うと下記エラーとなる。

#docker run -p 80:80 -p 443:443 -d --privileged centos:latest /sbin/init

docker: Error response from daemon: driver failed programming external
 connectivity on endpoint amazing_proskuriakova 
(65b0d6d847914cee8f6129bd36fed4d0a1c67843be6413d238f0c376af150950): Error 
starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use

結論

80番ポートであるapacheが起動していたから起こったエラーでした。

解決策

1.ポート番号をずらしてコマンドを実行してみる。

(sudo)docker run -p 88:88 -p 443:443 -d --privileged centos:latest /sbin/init

このようにポート番号を80ではなく88にずらして実行

2.すでに80番ポートで起動しているプロセスを終了する

[root@ip-172-31-28-29 ~]# lsof -i -P | grep "LISTEN"
rpcbind   2677      rpc    8u  IPv4  16507      0t0  TCP *:111 (LISTEN)
rpcbind   2677      rpc   11u  IPv6  16510      0t0  TCP *:111 (LISTEN)
httpd     3057     root    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
httpd     3093   apache    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
httpd     3094   apache    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
httpd     3095   apache    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
httpd     3096   apache    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
httpd     3097   apache    4u  IPv6  18359      0t0  TCP *:80 (LISTEN)
master    3200     root   13u  IPv4  18805      0t0  TCP localhost:25 (LISTEN)
sshd      3364     root    3u  IPv4  20172      0t0  TCP *:22 (LISTEN)
sshd      3364     root    4u  IPv6  20174      0t0  TCP *:22 (LISTEN)
container 3502     root    7u  IPv4  21589      0t0  TCP localhost:34781 (LISTE )

apacheが起動していました。

さっそく終了させます。

sudo apachectl stop

今思えば、以前にシステムがブートするたびに Apache ウェブサーバーが起動するように下記コマンドで設定していました。

sudo chkconfig httpd on
6
6
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
6
6