Introduction
This article is focusing on how to solve an error message as it exist in the title of this article. The error message is ‘error creating container storage: the container name “container_name” is already use by. Actually the error appear upon executing a command with podman. The command is to run a container using an specific image. The following is the execution of the comannd :
[podman@10 ~]$ podman run --privileged --name localhost-httpd -it -v /home/podman/website:/usr/local/apache2/htdocs -d httpd Error: error creating container storage: the container name "localhost-httpd" is already in use by "249fbda0edad894658f2d6cff85872f29e2def28ffb3ef33add195124ab47940". You have to remove that container to be able to reuse that name.: that name is already in use [podman@10 ~]$
Actually, executing the command above is a success in the previous step. But upon executing the above command twice, it actually ends in failure. This is the first execution of the command :
[podman@10 netns]$ podman run --name localhost-httpd -p 8080:80 -e TERM=xterm -d httpd 4752fcaaebf69c6d246fcb895434ce7306bed3614d1b12e04e3eebcb39a8427c [podman@10 netns]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9edd7f98363b docker.io/library/registry:2 /etc/docker/regis... 7 hours ago Up 7 hours ago 0.0.0.0:5000->5000/tcp adoring_leakey 4752fcaaebf6 docker.io/library/httpd:latest httpd-foreground 4 seconds ago Up 4 seconds ago 0.0.0.0:8080->80/tcp localhost-httpd [podman@10 netns]$
Solution
In the above output command execution, there is a container running with the name of ‘localhost-httpd’. It exist in the second or the last line in the above output execution. So, the container is already running. Executing the command twice will generate an error as it exist in the earlier part. It cannot run container with the same name. So, either use another name or just remove the old one and then execute it again. This article will show both of the solution display the latter solution.
First Solution
The first solution is just to use another container name. Just run it by changing the label name of the container. The following is the execution of the command :
[podman@10 ~]$ podman run --privileged --name another-localhost-httpd -it -v /home/podman/website:/usr/local/apache2/htdocs -p 7070:80 -d httpd 539e8c446eb706653eaac480e793fc7b4cba657723b4b911141df5e4ca09b7c7 [podman@10 ~]$
After successfully executing the above command, just execute another command to confirm the list of the container exist. The following is the display of the container running with the new one with the name of another-localhost-httpd.
[podman@10 website]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9edd7f98363b docker.io/library/registry:2 /etc/docker/regis... 11 hours ago Up 11 hours ago 0.0.0.0:5000->5000/tcp adoring_leakey faaded3b5ef2 docker.io/library/httpd:latest httpd-foreground 4 hours ago Up 4 hours ago 0.0.0.0:8080->80/tcp localhost-httpd 539e8c446eb7 docker.io/library/httpd:latest httpd-foreground 3 seconds ago Up 3 seconds ago 0.0.0.0:7070->80/tcp another-localhost-httpd [podman@10 website]$
Second Solution
Another solution, in this context it is the second solution is to remove the container and then run it again.The following are the steps to achieve it including to stop the container, to remove it and to run the container again :
[podman@10 ~]$ podman stop 4752fcaaebf6 4752fcaaebf69c6d246fcb895434ce7306bed3614d1b12e04e3eebcb39a8427c [podman@10 ~]$ podman rm 4752fcaaebf6 4752fcaaebf69c6d246fcb895434ce7306bed3614d1b12e04e3eebcb39a8427c [podman@10 ~]$
List the available container after executing the above command to confirm that the container is no longer exist :
[podman@10 ~]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9edd7f98363b docker.io/library/registry:2 /etc/docker/regis... 7 hours ago Up 7 hours ago 0.0.0.0:5000->5000/tcp adoring_leakey [podman@10 ~]$
Soon after, just run the container again using the same command as follows :
[podman@10 netns]$ podman run --name localhost-httpd -p 8080:80 -e TERM=xterm -d httpd 249fbda0edad894658f2d6cff85872f29e2def28ffb3ef33add195124ab47940 [podman@10 netns]$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9edd7f98363b docker.io/library/registry:2 /etc/docker/regis... 7 hours ago Up 7 hours ago 0.0.0.0:5000->5000/tcp adoring_leakey 249fbda0edad docker.io/library/httpd:latest httpd-foreground 10 seconds ago Up 9 seconds ago 0.0.0.0:8080->80/tcp localhost-httpd [podman@10 netns]$