docker - 在 docker 上绑定()到 0.0.0.0:80 失败(98:地址已在使用中)
问题描述
启动容器后出现
2019/03/09 17:33:58 [emerg] 81#0: still could not bind()
2019/03/09 17:34:01 [emerg] 82#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2019/03/09 17:34:01 [emerg] 82#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2019/03/09 17:34:01 [emerg] 82#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2019/03/09 17:34:01 [emerg] 82#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2019/03/09 17:34:01 [emerg] 82#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
Dockerfile内容查看github地址
https://github.com/zhengxidong/docker/blob/master/lnp7.2_supervisord_dockerfile/Dockerfile
使用supervisord
启动多个服务。Nginx配置文件配置daemon off;
没有出现错误日志,这是为什么?如果去掉daemon off;
,没有上面的错误。
解决方案
你已经运行了 nginx 两次:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 01:27 pts/0 00:00:00 /usr/bin/python /usr/bin/supervisord
root 9 1 0 01:27 pts/0 00:00:00 /usr/sbin/sshd -D
root 10 1 0 01:27 pts/0 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
root 11 1 0 01:27 pts/0 00:00:00 /usr/sbin/crond -n
root 12 1 0 01:27 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx <=============== Here
nginx 13 12 0 01:27 ? 00:00:00 nginx: worker process
nobody 14 10 0 01:27 pts/0 00:00:00 php-fpm: pool www
nobody 15 10 0 01:27 pts/0 00:00:00 php-fpm: pool www
root 68 0 0 01:29 pts/1 00:00:00 /bin/bash
root 84 1 0 01:29 pts/0 00:00:00 /usr/local/nginx/sbin/nginx <=== And Here
root 85 68 0 01:29 pts/1 00:00:00 ps -ef
第二个 nginx 无法运行,因为第一个已经运行。
注意
我建议您阅读编写 Dockerfile的最佳实践。您的图像在 10-15 分钟内创建。
推荐阅读
- google-api - 委托人(用户或服务账户)缺少资源的 IAM 权限“cloudtasks.tasks.create”
- python - 删除迁移文件夹后重置 Alembic
- labview - 我可以在LabVIEW中将数组传递给系统exec.vi吗?
- python - Python海龟图形填充问题
- macos - 文件采用不受支持的文本编码?
- asp.net - Asp.net 中的 Restful 服务获取信息
- spring-boot - 无法使用来自不同网络的 Spring Boot Rest 服务。但是,我可以使用同一台机器上的 api
- r - 使用grepl查找一定长度的字符串
- java - Java 对动态定义的对象数组列表进行排序
- c# - 使用 C# Visual Studio 将我的代码重写为方法