nignx - docker内nginx 80端口被占用
问题描述
[root@8f52078ea4e6 config]# nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] still could not bind()
docker容器配置的端口对应关系: 22/tcp, 0.0.0.0:80->80/tcp
问题解答
回答1:不是很确定,但是和docker的端口映射应该是没关系的,docker的关系映射相当于是再virtual box里面配了一个端口匹配规则,不会占用这个端口的,相当于外部端口转发到内部容器端口里。所以你这个错误应该是docker内部端口被占了。试一下lsof -i :80看看
回答2:用的什么镜像? 如果官方的nginx的话, nginx进程已经启动了, 这时你当然不能再在80上启动另一个
回答3:题主可以进入nginx的docker container实例,查看一下nginx是否已经启动:
ps -ef | grep nginx# ornetstat -ntpl | grep 80
如果已经启动,则不需要在重复启动了
回答4:你这已经是在容器中了吧,你的nginx容器启动后,80端口就已经起来了,你在运行nginx,肯定显示被占用了。
相关文章:
1. Mysql 关于 FOUND_ROWS() 和 ROW_COUNT() 函数2. 【python|scapy】sprintf输出时raw_string转string3. php中文网上的一个代码怎么实现的?4. javascript - 修改表单多选项时和后台同事配合的问题。5. java - canvas的问题,如何画出组合图形6. JS如何控制页面高度来决定是否显示查看更多7. javascript - 求助canvas绘制半透明的马赛克?8. java - Spring如何在启动时,针对特定的一类bean根据传入的参数创建出不同的实例并且在后续的业务中调用这些实例?9. javascript - webpack dllPlugin如何打包vendor到html里面?10. 安装mysql-5.7.12-linux后,启动报错,求解读