nignx - docker内nginx 80端口被占用

 U友50140932 发布于 2022-10-29 21:05

[root@8f52078ea4e6 config]# nginx
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] 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

4 个回答

  • 你这已经是在容器中了吧,你的nginx容器启动后,80端口就已经起来了,你在运行nginx,肯定显示被占用了。

    2022-10-31 19:51 回答
  • 题主可以进入nginx的docker container实例,查看一下nginx是否已经启动:

    ps -ef | grep nginx
    # or
    netstat -ntpl | grep 80

    如果已经启动,则不需要在重复启动了

    2022-10-31 19:51 回答
  • 用的什么镜像?
    如果官方的nginx的话, nginx进程已经启动了, 这时你当然不能再在80上启动另一个

    2022-10-31 19:52 回答
  • 不是很确定,但是和docker的端口映射应该是没关系的,docker的关系映射相当于是再virtual box里面配了一个端口匹配规则,不会占用这个端口的,相当于外部端口转发到内部容器端口里。
    所以你这个错误应该是docker内部端口被占了。试一下lsof -i :80看看

    2022-10-31 19:53 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有