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.刪除鏡像/網(wǎng)絡/容器/掛在目錄
?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