启动/删除Docker容器时出现问题 - 如何修复


使用Docker过程中,运行docker-compose up或docker run时,出现Conflict. The name W is already in use by container XYZ. You have to delete..或"Conflict, cannot remove the default name of the container..." 
或:Conflict. The name "XYZ" is already in use by container hexacode. You have to delete (or rename) that container to be able to reuse that name.

我们无法启动容器,因为该名称已在使用中。运行docker ps命令,又看不到。

运行docker ps -a

找到你的容器,复制它的Id号,然后运行:

docker rm 85c2981e63f6 26ea04f41ab3 

删除后,再运行docker-compose up

第二种方法是从/ var下手动删除剩余的文件。具体来说,可以在/ var / lib / docker / containers /下找到这些文件。每个容器目录都有一个超长的哈希标识符,里面有大量丑陋的JSON输出。如果搜索与所需容器名称匹配的特定字符串,则会找到包含其配置文件的相关目录。
删除与名称搜索匹配的父目录,然后重新启动Docker服务。之后,您应该可以再次使用您的名字。