Bind for 0.0.0.0:8181 failed: port is already allocated

Docker 错误 “port is already allocated” 解决方法
Docker 在启动容器时,报出了下面的错误:

docker: Error response from daemon: driver failed programming external connectivity on endpoint … (…): Bind for 0.0.0.0:8080 failed: port is already allocated.

查看进程,发现相关的容器并没有在运行,而 docker-proxy 却依然绑定着端口:


$ docker ps
$ ps -aux | grep -v grep | grep docker-proxy

ps -aux | grep -v grep | grep gitlab-gitlab-1

停止 doker 进程,删除所有容器,然后删除 local-kv.db 这个文件,再启动 docker 就可以了。


$ sudo service docker stop
$ docker rm $(docker ps -aq)
$ sudo rm /var/lib/docker/network/files/local-kv.db
$ sudo systemctl restart docker
文档更新时间: 2023-08-03 08:42   作者:admin