CentOS Stream 10
Sponsored Link

Podman : Use Registry2025/01/21

 

Install Registry to build Private Registry for Podman images.

Pull the Registry image and run it. Container images are located under [/var/lib/regstry] on Registry v2 Container,
so map to mount [/var/lib/containers/registry] on parent Host for Registry Container to use as Persistent Storage.

[1] Configure Registry.
This is for the case to use HTTP and no authentication.
[root@dlp ~]#
podman pull registry

[root@dlp ~]#
mkdir /var/lib/containers/registry

# if SELinux is [Enforcing], add [--privileged] option

[root@dlp ~]#
podman run --privileged -d -p 5000:5000 \
-v /var/lib/containers/registry:/var/lib/registry \
registry
[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                              COMMAND               CREATED        STATUS        PORTS                   NAMES
230a8c4fe195  docker.io/library/registry:latest  /etc/docker/regis...  4 seconds ago  Up 4 seconds  0.0.0.0:5000->5000/tcp  thirsty_chatelet

# if Firewalld is running, allow ports

[root@dlp ~]#
firewall-cmd --add-port=5000/tcp

[root@dlp ~]#
firewall-cmd --runtime-to-permanent
# verify to push to Registry from localhost
# for HTTP connection, add [--tls-verify=false] option

[root@dlp ~]#
podman tag centos:stream10 dlp.srv.world:5000/centos:stream10

[root@dlp ~]#
podman push dlp.srv.world:5000/centos:stream10 --tls-verify=false

Getting image source signatures
Copying blob 37e999dd80a5 done   |
Copying config 1ef274445e done   |
Writing manifest to image destination

[root@dlp ~]#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED            SIZE
srv.world/centos-nginx      latest      d64d577f9a9e  About an hour ago  347 MB
srv.world/centos-httpd      latest      ff3843182253  2 hours ago        354 MB
dlp.srv.world:5000/centos   stream10    1ef274445e32  7 days ago         311 MB
quay.io/centos/centos       stream10    1ef274445e32  7 days ago         311 MB
docker.io/library/registry  latest      282bd1664cf1  15 months ago      26 MB
[2] To enable Basic authentication, Configure like follows.
[root@dlp ~]#
dnf -y install httpd-tools
# add users for Registry authentication

[root@dlp ~]#
htpasswd -Bc /etc/containers/.htpasswd cent

New password:
Re-type new password:
Adding password for user cent

[root@dlp ~]#
podman run --privileged -d -p 5000:5000 \
-v /var/lib/containers/registry:/var/lib/registry \
-v /etc/containers:/auth \
-e REGISTRY_AUTH=htpasswd \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/.htpasswd \
-e REGISTRY_AUTH_HTPASSWD_REALM="Registry Realm" \
registry
# login as a user you added above

[root@dlp ~]#
podman login dlp.srv.world:5000 --tls-verify=false

Username: cent
Password:
Login Succeeded!

[root@dlp ~]#
podman tag centos:stream10 dlp.srv.world:5000/centos:stream10

[root@dlp ~]#
podman push dlp.srv.world:5000/centos:stream10 --tls-verify=false

[root@dlp ~]#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED        SIZE
srv.world/centos-nginx      latest      d64d577f9a9e  4 hours ago    347 MB
srv.world/centos-httpd      latest      ff3843182253  5 hours ago    354 MB
dlp.srv.world:5000/centos   stream10    1ef274445e32  7 days ago     311 MB
quay.io/centos/centos       stream10    1ef274445e32  7 days ago     311 MB
docker.io/library/registry  latest      282bd1664cf1  15 months ago  26 MB
[3] This is for the case you set valid certificate like Let's Encrypt and enable HTTPS connection.
This example is based on that certificate were created under the [/etc/letsencrypt] directory.
[root@dlp ~]#
podman run --privileged -d -p 5000:5000 \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/fullchain.pem \
-e REGISTRY_HTTP_TLS_KEY=/certs/privkey.pem \
-v /etc/letsencrypt/live/dlp.srv.world:/certs \
-v /var/lib/containers/registry:/var/lib/registry \
registry
# verify to push to Registry

[root@node01 ~]#
podman tag centos:stream10 dlp.srv.world:5000/centos:stream10

[root@node01 ~]#
podman push dlp.srv.world:5000/centos:stream10

[root@node01 ~]#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED        SIZE
srv.world/centos-nginx      latest      d64d577f9a9e  4 hours ago    347 MB
srv.world/centos-httpd      latest      ff3843182253  5 hours ago    354 MB
dlp.srv.world:5000/centos   stream10    1ef274445e32  7 days ago     311 MB
quay.io/centos/centos       stream10    1ef274445e32  7 days ago     311 MB
docker.io/library/registry  latest      282bd1664cf1  15 months ago  26 MB
Matched Content