Podman : Use Registry2025/08/22 |
|
Install Docker-Registry to build Private Registry for Docker images. |
|
| [1] | Install Registry. |
|
root@dlp:~# apt -y install docker-registry
|
| [2] | Configure Registry. This is the settings to use HTTP connection and no-authentication. |
|
root@dlp:~#
vi /etc/docker/registry/config.yml # comment out [auth] section like follows
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/docker-registry
delete:
enabled: true
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
#auth:
# htpasswd:
# realm: basic-realm
# path: /etc/docker/registry/htpasswd
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
root@dlp:~#
systemctl restart docker-registry
# verify possible to access from any clients root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/debian-nginx latest 33b7b5b10b13 17 minutes ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 25 minutes ago 234 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB # [push] from localhost root@dlp:~# podman tag debian dlp.srv.world:5000/debian:my-registry root@dlp:~# podman push dlp.srv.world:5000/debian:my-registry --tls-verify=false root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/debian-nginx latest 33b7b5b10b13 18 minutes ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 26 minutes ago 234 MB dlp.srv.world:5000/debian my-registry 047bd8d81940 11 days ago 124 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB # [pull] from another node root@node01:~# podman pull dlp.srv.world:5000/debian:my-registry --tls-verify=false root@node01:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE dlp.srv.world:5000/debian my-registry 047bd8d81940 11 days ago 124 MB |
| [3] | To enable Basic authentication, Configure like follows. |
|
root@dlp:~#
apt -y install apache2-utils
root@dlp:~#
vi /etc/docker/registry/config.yml # uncomment [auth] section and specify passwd file
.....
.....
auth:
htpasswd:
realm: basic-realm
path: /etc/containers/registries.conf.d/.htpasswd
.....
.....
# add users # add [-c] at initial file creation root@dlp:~# htpasswd -Bc /etc/containers/registries.conf.d/.htpasswd debian New password: Re-type new password: Adding password for user debian
root@dlp:~#
systemctl restart docker-registry
# verify possible to access # an error is shown if access with no-authentication root@node01:~# podman pull dlp.srv.world:5000/debian:my-registry --tls-verify=false Trying to pull dlp.srv.world:5000/debian:my-registry... Error: initializing source docker://dlp.srv.world:5000/debian:my-registry: reading manifest my-registry in dlp.srv.world:5000/debian: authentication required # authenticate by a user added with [htpasswd] root@node01:~# podman login dlp.srv.world:5000 --tls-verify=false
Username: debian
Password:
Login Succeeded!
root@node01:~# podman pull dlp.srv.world:5000/debian:my-registry --tls-verify=false root@node01:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE dlp.srv.world:5000/debian my-registry 047bd8d81940 11 days ago 124 MB |
| [4] | To access via HTTPS and use valid certificates like from Let's Encrypt and so on, Configure like follows. This example is based on the environment that certificates have been gotten under the [/etc/letsencrypt/live/dlp.srv.world]. |
|
root@dlp:~# cp -p /etc/letsencrypt/live/dlp.srv.world/{fullchain,privkey}.pem /etc/containers/registries.conf.d/ root@dlp:~# chown docker-registry /etc/containers/registries.conf.d/{fullchain,privkey}.pem
root@dlp:~#
vi /etc/docker/registry/config.yml # add [tls] section under the [http] section like follows
.....
.....
http:
addr: :5000
tls:
certificate: /etc/containers/registries.conf.d/fullchain.pem
key: /etc/containers/registries.conf.d/privkey.pem
headers:
X-Content-Type-Options: [nosniff]
.....
.....
root@dlp:~#
systemctl restart docker-registry
# verify possible to access # on HTTPS connection, it does not need to add [insecure-registries] on Docker root@node01:~# podman pull dlp.srv.world:5000/debian:my-registry root@node01:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE dlp.srv.world:5000/debian my-registry 047bd8d81940 11 days ago 124 MB |
| Sponsored Link |
|
|