How to Solve Error Message Error: error creating container storage: the container name is already in use when executing podman

Posted on

Introduction

This is an article where the main focus is how to solve the error message appear when executing podman. The error message exist as part of it in the title of this article. It is when the execution of podman command is aiming to run a container. The following is the full output of the command execution :

[admin@10 ~]$ podman run --privileged -d --name registry -p 5000:5000 -v /var/lib/registry:/var/lib/registry --restart=always registry:2
Error: error creating container storage: the container name "registry" is already in use by "ec4154e818a02a590c46456702478f461195ea7dfc375e3ad7fa14269e51278e". You have to remove that container to be able to reuse that name.: that name is already in use
[admin@10 ~]$

So, check the available container first by running the following command :

[admin@10 ~]$ podman ps -a --pod
CONTAINER ID  IMAGE                         COMMAND               CREATED     STATUS                 PORTS                   NAMES     POD ID  PODNAME
ec4154e818a0  docker.io/library/registry:2  /etc/docker/regis...  4 days ago  Exited (2) 4 days ago  0.0.0.0:5000->5000/tcp  registry
[admin@10 ~]$

The output of the above command execution is showing that there already a container with the name of ‘registry’. So, that is the main reason for the failing execution of the command.

Solution

The solution for solving the error message appear are actually simple. There are two alternative solutions to solve the error message. The first one is just to start the existing container. The second one is more difficult. It is removing the old container and the create a new one by running it. So, this part will only show how to start it by executing the command as follows :

[admin@10 ~]$ podman start registry
registry
[admin@10 ~]$

The command pattern for the above command execution is ‘podman start container_name’. In this context, the name of the container is ‘registry’. So, the command execution is obvious will be ‘podman start registry’. After starting the container, try to check the status of the container once more as follows :

[admin@10 ~]$ podman ps
CONTAINER ID  IMAGE                         COMMAND               CREATED     STATUS            PORTS                   NAMES
ec4154e818a0  docker.io/library/registry:2  /etc/docker/regis...  4 days ago  Up 5 seconds ago  0.0.0.0:5000->5000/tcp  registry
[admin@10 ~]$

So, the command for starting or running the container once more to solve the error message ends with a success.

Leave a Reply