head-img Force's Blog

docker-compose up报错:ERROR: for xxx Cannot create container for service xxx: Conflict. The container name "/xxx" is already in use by container "xxxxxxxxxx"

docker,DevOps

Docker报错:ERROR: for xxx Cannot create container for service xxx: Conflict. The container name "/xxx" is already in use by container "xxxxxxxxxx"

这是因为同名容器已存在,即使不使用也会报错

解决办法,先执行docker ps -a查看冲突的容器

[root@localhost] docker ps -a
CONTAINER ID   IMAGE               COMMAND                  CREATED             STATUS                      PORTS     NAMES
8d552e3940ee   sunyawechat_nginx   "/docker-entrypoint.…"   About an hour ago   Exited (0) 31 minutes ago             nginx
e8f1b06a15a7   sunyawechat_php     "docker-php-entrypoi…"   About an hour ago   Exited (0) 31 minutes ago             php
bcd8e3b8ec86   mysql:5.7.28        "docker-entrypoint.s…"   About an hour ago   Exited (2) 31 minutes ago             mysql5

对着CONTAINER ID删除冲突的容器,我这里是三个容器都是冲突所以都删掉

docker container rm 8d552e3940ee
docker container rm e8f1b06a15a7
docker container rm bcd8e3b8ec86

重启启动

docker-compose up

#没有错误了ok!了
点我评论
打赏本文
二维码


99

文章

24

标签

 推广