Solved: Error when allocating new name – Docker

Error response from daemon: Error when allocating new name: Conflict. The container name "/webserver" is already in use by container 6c34a8wetwyetwy7463462d329c9601812tywetdyud76767d65f7dc7ea58d8541. You have to remove (or rename) that container to be able to reuse that name.

If you see the above error it is because a container with same name exist.

Let’s check our running containers

docker container ls

If you don’t see any running container with that name, check the stopped containers.

docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b45bd14c8987 1fbd5d581e4c "/bin/bash" 2 minutes ago Up 2 minutes competent_keller
59b9f5a63ba0 ansible-base "/bin/base" 3 minutes ago Created wizardly_payne
6c34a8a6edb6 d355ed3537e9 "/bin/bash" 9 minutes ago Exited (0) 4 minutes ago webserver

Above we can see that we already have a container with name webserver.

 

Green Monday Sale! Never stop learning, courses now as low as $10.99

So we will rename the old container.

docker rename webserver webserver_old

Now if we check again. Our container is renamed to webserver_old .

docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b45bd14c8987 1fbd5d581e4c "/bin/bash" 4 minutes ago Up 4 minutes competent_keller
59b9f5a63ba0 ansible-base "/bin/base" 5 minutes ago Created wizardly_payne
6c34a8a6edb6 d355ed3537e9 "/bin/bash" 10 minutes ago Exited (0) 5 minutes ago webserver_old

And if you don’t need the old container you can also delete it to free up the space.

docker rm webserver_old

Now if you try to create a container with “webserver” name you should not get any error.

Leave a Reply

Your email address will not be published. Required fields are marked *