首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker Nginx镜像启动,但失败,出现端口已在使用中错误

Docker Nginx镜像启动,但失败,出现端口已在使用中错误
EN

Stack Overflow用户
提问于 2019-10-13 23:31:18
回答 1查看 358关注 0票数 0

我有一个带有alphine-nginx镜像的docker容器。我将5个Nginx配置文件推送到这个容器中,但它不工作,并且在容器中出现“端口已在使用”的情况下失败。每个配置文件都包含不同的端口,但在启动时失败。

error.log具有:

代码语言:javascript
复制
019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:80 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2447 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2450 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2448 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to 0.0.0.0:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: bind() to [::]:2449 failed (98: Address in use)
2019/10/13 14:57:17 [emerg] 21#21: still could not bind()

netstat -ltnp信息:

代码语言:javascript
复制
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.11:33623        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2447            0.0.0.0:*               LISTEN      9/nginx: master pro
tcp        0      0 0.0.0.0:2448            0.0.0.0:*               LISTEN      9/nginx: master pro
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9/nginx: master pro
tcp        0      0 0.0.0.0:2449            0.0.0.0:*               LISTEN      9/nginx: master pro
tcp        0      0 0.0.0.0:2450            0.0.0.0:*               LISTEN      9/nginx: master pro
tcp        0      0 :::2447                 :::*                    LISTEN      9/nginx: master pro
tcp        0      0 :::2448                 :::*                    LISTEN      9/nginx: master pro
tcp        0      0 :::80                   :::*                    LISTEN      9/nginx: master pro
tcp        0      0 :::2449                 :::*                    LISTEN      9/nginx: master pro
tcp        0      0 :::2450                 :::*                    LISTEN      9/nginx: master pro

如我所见,有些东西开始了Nginx,但是怎么检查它是什么呢?

Docker ps:

EN

回答 1

Stack Overflow用户

发布于 2019-10-13 23:51:50

你有一个进程的id (PID)的进程,它已经取得了端口。您可以使用ps -p 9 -o comm=获取此过程的命令行。

我想是码头。在这种情况下,尝试使用docker ps获取正在运行的docker容器的列表。

你可以通过kill -9 9来终止这个进程。

更新:我尝试过用docker run nginx:1.17.4-alpine运行容器,没有任何问题。如果您构建自定义镜像或使用与默认设置不同的其他设置或配置,则需要对其进行描述。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58365048

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档