ERROR:for server Cannotstart service server: driver failed programming external connectivityon endpoint server_1 (2bf20c2fa34592fa3c62178c384c2b1697ca5742af28ed7b25b1261bdd0908b9):Bind
for 0.0.0.0:5002 failed: port is alreadyallocated
ERROR:for server Cannot start server: driver failed programming external connectivity on endpoint server_1(2bf20c2fa34592fa3c62178c384c2b1697ca5742af28ed7b25b1261bdd0908b9): Bind for0.0.0.
0:5002failed: port is already allocatedERROR: Encountered errors while bringing upthe project.
描述:gitlab CI时,docker-compose部署服务时,报错端口被占用,且端口不能改变
方法:
1.使用docker-compose down server
netstat-anput | grep 5002
在启动看看是否可用
2.删除镜像/网络/容器/挂在目录
docker network rm serverID
docker container rm serverID
docker volume rm serverID
docker image rm serverID
重启server
3.重启docker
systemctlrestart docker
4.没测试(慎用,有可能将所有服务的network删除)
sudo cp/var/lib/docker/network/files/local-kv.db /var/lib/docker/network/files/local-kv.db_bk
sudo rm/var/lib/docker/network/files/local-kv.db
sudodocker-compose up -d
网友评论