Summary: As part of everyday code deploy, we started seeing the ‘Conflict. The name “/container-A” is already in use by container 121ksdlfksdf. You have to remove (or rename) that container to be able to reuse that name.’ error.
“docker ps -a” did not show the container-A. “grep -r -e ‘container-ID/Name’ /var/lib/docker/” did not show any match in the filesystem.
Fix: Whenever this happens (2 episodes so far), we take the following actions to fix the issue. Note that, if we do not stop and start (line 4,5), the issue persists. Maybe this is a memory related issue in version 1.11.2.
docker stop $(docker ps -q)
docker rm $(docker ps -aa)
docker rmi $(docker images -q)
systemctl stop docker
systemctl start docker
docker-compose up
Feedback on how community is tackling this issue is welcome!
Thanks
I also encountered this issue when attempting to deploy a simple web app to Docker Cloud using dockercloud/haproxy as a proxy container. Unfortunately, I didn’t see this thread to try the suggested steps to fix.
update:
Appears to only be happening when using Docker Cloud with with a “bring your own node” installation on CentOS.
We can reproduce this running: while true; do name=test1; docker run -d --name $name --net test nginx; docker stop $name; docker rm -f $name; done
Letting this run for a couple of minutes often results in: The name “/test1” is already in use by container 5ad7ea21bbff935e4d137f0887784868128dbf179b26a0421a8b4abd960fc17d