linux进18080端口,Linux端口被占用如何处理

启用docker容器报端口被占用:

[root@takeout docker]# docker-compose -f appDev.yml up -d

docker_seaweedfs-volume_1 is up-to-date

docker_seaweedfs-master_1 is up-to-date

docker_zookeeper_1 is up-to-date

docker_seaweedfs-filer_1 is up-to-date

docker_catering-mysql_1 is up-to-date

docker_seaweedfs-cronjob_1 is up-to-date

docker_seaweedfs-s3_1 is up-to-date

docker_kafka_1 is up-to-date

Creating docker_catering-app_1 ... error

ERROR: for docker_catering-app_1 Cannot start service catering-app: driver failed programming external connectivity on endpoint docker_catering-app_1 (44b6313f082745c9e222d199c385c36a088e687fa785688b54f56875a4d2d62c): Bind for 0.0.0.0:8081 failed: port is already allocated

ERROR: for catering-app Cannot start service catering-app: driver failed programming external connectivity on endpoint docker_catering-app_1 (44b6313f082745c9e222d199c385c36a088e687fa785688b54f56875a4d2d62c): Bind for 0.0.0.0:8081 failed: port is already allocated

ERROR: Encountered errors while bringing up the project.

[root@takeout docker]#

查看端口被哪个PID占用:

[root@takeout docker]# lsof -i |grep 8081

[root@takeout docker]# netstat -tnlp | grep 8081

删除占用端口的进程:

[root@takeout docker]# kill -9 [PID]

如果启用应用的时候,还是报端口被占用,

查看防火墙规则:

[root@takeout docker]# iptables -t nat -nL --line-number |grep 8081

16 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8081 to:172.18.0.10:8080

[root@takeout docker]#

清空防火墙规则:

[root@takeout docker]# iptables -t nat -F

再重启应用,还是报端口被占用,

这是因为 docker-proxy 依然绑定着端口

查看docker-proxy占用端口的情况:

[root@takeout docker]# ps -aux | grep -v grep | grep docker-proxy

root 12228 0.0 0.0 0 0 ? Z 10:01 0:04 [docker-proxy]

root 17234 0.0 0.0 116376 76 ? Sl 3月31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 53380 -container-ip 172.18.0.2 -container-port 8080

root 17246 0.0 0.0 181912 60 ? Sl 3月31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 18080 -container-ip 172.18.0.2 -container-port 18080

root 17460 0.0 0.0 190108 108 ? Sl 3月31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 19333 -container-ip 172.18.0.5 -container-port 19333

root 17473 0.0 0.0 268928 0 ? Sl 3月31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9333 -container-ip 172.18.0.5 -container-port 9333

root 19671 0.0 0.0 181912 48 ? Sl 3月18 0:03 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8333 -container-ip 172.18.0.3 -container-port 8333

root 19726 0.0 0.0 190108 48 ? Sl 3月18 0:03 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 18888 -container-ip 172.18.0.4 -container-port 18888

root 19776 0.0 0.0 781180 320 ? Sl 3月18 1:28 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.18.0.4 -container-port 8888

root 20231 0.0 0.0 116376 68 ? Sl 3月18 0:03 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2181 -container-ip 172.18.0.6 -container-port 2181

root 20246 0.0 0.0 181912 48 ? Sl 3月18 0:03 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3306 -container-ip 172.18.0.7 -container-port 3306

root 20258 0.0 0.0 190108 48 ? Sl 3月18 0:03 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9092 -container-ip 172.18.0.8 -container-port 9092

root 30790 0.0 0.0 116376 72 ? Sl 4月07 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.17.0.2 -container-port 80

[root@takeout docker]#

实在没有招了,只能重启docker服务

systemctl restart docker

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值