Ubuntu 22.04
Sponsored Link

Podman : Use Registry
2022/04/28
 
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:2

root@dlp:~#
mkdir /var/lib/containers/registry

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

CONTAINER ID  IMAGE                         COMMAND               CREATED        STATUS            PORTS                   NAMES
6ce4c23a4d02  docker.io/library/registry:2  /etc/docker/regis...  4 seconds ago  Up 5 seconds ago  0.0.0.0:5000->5000/tcp  mystifying_booth

# verify to push to Registry from localhost
# for HTTP connection, add [--tls-verify=false] option

root@dlp:~#
podman tag ubuntu dlp.srv.world:5000/ubuntu:latest

root@dlp:~#
podman push dlp.srv.world:5000/ubuntu:latest --tls-verify=false

Getting image source signatures
Copying blob b401a928648a done
Copying config 3f4714ee06 done
Writing manifest to image destination
Storing signatures

root@dlp:~#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED         SIZE
srv.world/ubuntu-nginx      latest      00787fa1628b  24 minutes ago  170 MB
srv.world/ubuntu-apache2    latest      c5d3a78bc38f  28 minutes ago  224 MB
docker.io/library/ubuntu    latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu   latest      3f4714ee068a  6 days ago      80.3 MB
docker.io/library/registry  2           2e200967d166  3 weeks ago     24.7 MB
[2] To enable Basic authentication, Configure like follows.
root@dlp:~#
apt -y install apache2-utils
# add users for Registry authentication

root@dlp:~#
htpasswd -Bbc /etc/containers/.htpasswd ubuntu

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

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:2
# login as a user you added above

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

Username: ubuntu
Password:
Login Succeeded!

root@dlp:~#
podman tag ubuntu dlp.srv.world:5000/ubuntu2:latest

root@dlp:~#
podman push dlp.srv.world:5000/ubuntu2:latest --tls-verify=false

root@dlp:~#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED         SIZE
srv.world/ubuntu-nginx      latest      00787fa1628b  26 minutes ago  170 MB
srv.world/ubuntu-apache2    latest      c5d3a78bc38f  31 minutes ago  224 MB
docker.io/library/ubuntu    latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu   latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu2  latest      3f4714ee068a  6 days ago      80.3 MB
docker.io/library/registry  2           2e200967d166  3 weeks ago     24.7 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:2
# verify to push to Registry

[root@node01 ~]#
podman tag ubuntu dlp.srv.world:5000/ubuntu3:latest

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

[root@node01 ~]#
podman images

REPOSITORY                  TAG         IMAGE ID      CREATED         SIZE
srv.world/ubuntu-nginx      latest      00787fa1628b  26 minutes ago  170 MB
srv.world/ubuntu-apache2    latest      c5d3a78bc38f  31 minutes ago  224 MB
docker.io/library/ubuntu    latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu   latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu2  latest      3f4714ee068a  6 days ago      80.3 MB
dlp.srv.world:5000/ubuntu3  latest      fe3c5de03486  6 days ago      80.3 MB
docker.io/library/registry  2           2e200967d166  3 weeks ago     24.7 MB
Matched Content