How to Start and Run Local Image Repository Container using Podman in Linux CentOS 8

Posted on

Introduction

This article has a relation with a previous article. That previous article is an article with the title of ‘How to Setup Local Image Repository with Podman in Linux CentOS 8’ in this link. Basically, it is to show how to start an existing local image repository container using podman. But after shutting down the virtual server or restarting it, the local image respository container is stop. So, after the executing the command to start it again, an error message appear. It is actually the same error message as in the article exist in this link. The article’s title is ‘How to Solve Error Message Error: error creating container storage: the container name is already in use when executing podman’.

So, the following is the actual execution of to run the local image repository container using podman :

[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 ~]$

Another way for running the container which is already exist is just by starting it. The command execution for starting the container exist as follows :

[admin@10 ~]$ podman start registry
registry
[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 ~]$

Running Local Image Repository Server Container using root account

As an information, there is a different between running the local image repository container among different user or account in the operating system. For an example, if there is never been any submit, tag or pull to the repository using a user, there will be no image available in the execution of ‘podman images’ command.

But on the other hand, if in another user account, it has already been done, it is a different story. It will share the list of those images across the user account. For example, the following is the output of listing the container and image using the account with the name of ‘admin’ :

[admin@10 ~]$ podman ps
CONTAINER ID  IMAGE   COMMAND  CREATED  STATUS  PORTS   NAMES
[admin@10 ~]$ podman stop registry
ec4154e818a02a590c46456702478f461195ea7dfc375e3ad7fa14269e51278e
[admin@10 ~]$
[admin@10 ~]$ podman ps -a
CONTAINER ID  IMAGE                         COMMAND               CREATED     STATUS                  PORTS                   NAMES
ec4154e818a0  docker.io/library/registry:2  /etc/docker/regis...  4 days ago  Exited (2) 2 hours ago  0.0.0.0:5000->5000/tcp  registry
[admin@10 ~]$ podman images
REPOSITORY                     TAG     IMAGE ID      CREATED       SIZE
docker.io/library/httpd        latest  f3cffeea581b  11 days ago   142 MB
docker.io/library/registry     2       1fd8e1b0bb7e  5 weeks ago   26.8 MB
docker.io/library/hello-world  latest  d1165f221234  2 months ago  20 kB
[admin@10 ~]$

Compare it with the one using the ‘root account’ as follows :

[admin@10 ~]$ sudo su -
[sudo] password for admin:
Last login: Sun May 23 03:24:45 EDT 2021 on pts/0
[root@10 ~]# podman ps
CONTAINER ID  IMAGE                          COMMAND               CREATED      STATUS          PORTS                   NAMES
c1107efbfed4  docker.io/library/registry:2   /etc/docker/regis...  4 weeks ago  Up 2 hours ago  0.0.0.0:5000->5000/tcp  registry
08aa9031f3ab  localhost:5000/httpd-template  httpd-foreground      2 hours ago  Up 2 hours ago  0.0.0.0:8080->80/tcp    local_httpd
[root@10 ~]# podman ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED      STATUS                 PORTS                   NAMES
c1107efbfed4  docker.io/library/registry:2    /etc/docker/regis...  4 weeks ago  Up 2 hours ago         0.0.0.0:5000->5000/tcp  registry
aa9a9a9813c2  docker.io/library/httpd:latest  httpd-foreground      2 days ago   Exited (0) 2 days ago  0.0.0.0:8080->80/tcp    my_httpd
08aa9031f3ab  localhost:5000/httpd-template   httpd-foreground      2 hours ago  Up 2 hours ago         0.0.0.0:8080->80/tcp    local_httpd
[root@10 ~]# podman images
REPOSITORY                     TAG     IMAGE ID      CREATED       SIZE
localhost/httpd-template       latest  fad3e1369c4e  2 days ago    142 MB
localhost:5000/httpd-template  latest  fad3e1369c4e  2 days ago    142 MB
docker.io/library/httpd        latest  f3cffeea581b  11 days ago   142 MB
docker.io/library/registry     2       1fd8e1b0bb7e  5 weeks ago   26.8 MB
docker.io/library/hello-world  latest  d1165f221234  2 months ago  20 kB
[root@10 ~]#
[root@10 ~]# podman start registry
[root@10 ~]# podman ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED      STATUS                 PORTS                   NAMES
c1107efbfed4  docker.io/library/registry:2    /etc/docker/regis...  4 weeks ago  Up 2 hours ago         0.0.0.0:5000->5000/tcp  registry
aa9a9a9813c2  docker.io/library/httpd:latest  httpd-foreground      2 days ago   Exited (0) 2 days ago  0.0.0.0:8080->80/tcp    my_httpd
08aa9031f3ab  localhost:5000/httpd-template   httpd-foreground      2 hours ago  Up 2 hours ago         0.0.0.0:8080->80/tcp    local_httpd
[root@10 ~]#

So, the are difference on the list of the images and also containers between different user account. It depends on the user or the account whom execute to run the local server image repository server.

Leave a Reply