解決docker-compose啟動報錯


准備好安裝nginx的yaml文件

[root@node1 docker_nginx]# cat docker-compose.yml 
version: '3.1'
services:
        nginx:
                restart: always
                image: daocloud.io/library/nginx:latest
                container_name: nginx
                ports:
                        - 80:80

報錯

[root@node1 docker_nginx]# docker-compose up -d
Creating network "docker_nginx_default" with the default driver
Pulling nginx (daocloud.io/library/nginx:latest)...
Trying to pull repository daocloud.io/library/nginx ... 
latest: Pulling from daocloud.io/library/nginx
bf5952930446: Pull complete
cb9a6de05e5a: Pull complete
9513ea0afb93: Pull complete
b49ea07d2e93: Pull complete
a5e4a503d449: Pull complete
Digest: sha256:179412c42fe3336e7cdc253ad4a2e03d32f50e3037a860cf5edbeb1aaddb915c
Status: Downloaded newer image for daocloud.io/library/nginx:latest
Creating nginx ... error

ERROR: for nginx  Cannot start service nginx: driver failed programming external connectivity on endpoint nginx (a97f562ec97962fea3fbe29cc84f2d92bf971bad6a5d0658323b348bfb7aae3b): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use

ERROR: for nginx  Cannot start service nginx: driver failed programming external connectivity on endpoint nginx (a97f562ec97962fea3fbe29cc84f2d92bf971bad6a5d0658323b348bfb7aae3b): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
ERROR: Encountered errors while bringing up the project.
[root@node1 docker_nginx]# lsof -i:80
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   66557   root    4u  IPv6 378430      0t0  TCP *:http (LISTEN)
httpd   66558 apache    4u  IPv6 378430      0t0  TCP *:http (LISTEN)
httpd   66559 apache    4u  IPv6 378430      0t0  TCP *:http (LISTEN)
httpd   66560 apache    4u  IPv6 378430      0t0  TCP *:http (LISTEN)
httpd   66561 apache    4u  IPv6 378430      0t0  TCP *:http (LISTEN)
httpd   66562 apache    4u  IPv6 378430      0t0  TCP *:http (LISTEN)

如上錯誤信息很明了,80端口被httpd占用了,關掉docker-compose,修改docker-compose.yml端口為8001解決問題

[root@node1 docker_nginx]# docker-compose down
Removing nginx ... done
Removing network docker_nginx_default
[root@node1 docker_nginx]# docker-compose up -d
Creating network "docker_nginx_default" with the default driver
Creating nginx ... done


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM