解决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