DEV Community

Cover image for How to Set Up a Local Podman Registry and Customize Podman Images
Project-42
Project-42

Posted on • Edited on

How to Set Up a Local Podman Registry and Customize Podman Images

It is never bad idea to keep local container repositories, specially if you need to add modifications to the containers for your specific environment

This will also will make easier some local testing

1. Create a Local Podman Registry

1.1. Pull and run the registry image.

Run this command to start a registry on port 5000:

[|=| raspi in ~ ]$ podman run -d -p 5000:5000 --restart=always --name local-registry registry:2
Resolved "registry" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/registry:2...
Getting image source signatures
Copying blob bd39ca3613a6 done   |
Copying blob ddcb6d98388d done   |
Copying blob 9a6b3f59ebc2 done   |
Copying blob 8bbaad1488a8 done   |
Copying blob 95459497489f done   |
Copying config 33eeff39e0 done   |
Writing manifest to image destination
39954e773035d07c13f5f458a8e16a39ffa4e171649792287c38af9646866bd2
Enter fullscreen mode Exit fullscreen mode

1.2. Configure "Insecure" access.

By default, Podman expects registries to use HTTPS. For a local setup, you need to tell Podman it’s okay to use HTTP for localhost.
Edit (or create) /etc/containers/registries.conf and add the following registry entry
Be careful, if you have a specific regitries conf file for the user creating the container, you need to modify that file (default location is /home/{solifugo}/.config/containers/registries.conf)

[|=| raspi in ~ ]$ ls -lrth /etc/containers/registries.conf
-rw-r--r-- 1 root root 3.8K Mar  7  2025 /etc/containers/registries.conf

[|=| raspi in ~ ]$ sudo nano /etc/containers/registries.conf

[|=| raspi in ~ ]$ tail -5 /etc/containers/registries.conf
# # 3. internal-registry-for-example.com/bar/image:latest
# # in order, and use the first one that exists.
[[registry]]
location = "localhost:5000"
insecure = true

[|=| raspi in ~ ]$
Enter fullscreen mode Exit fullscreen mode

2. Modify a WordPress Container Image

The best way to modify an image is via a Containerfile (Podman's version of a Dockerfile).
In this example we increase the PHP upload limit:

2.1. Create your Containerfile

[|=| raspi in ~ ]$ cd /home/solifugo/pods/p42_wordpress
[|=| raspi in ~/pods/p42_wordpress ]$ cat Containerfile
# Use the official WordPress image as a base
FROM docker.io/library/wordpress:latest

# Example: Increase the upload size by creating a custom PHP config
RUN echo 'file_uploads = On\nmemory_limit = 256M\nupload_max_filesize = 64M\npost_max_size = 64M\nmax_execution_time = 300' > /usr/local/etc/php/conf.d/uploads.ini

[|=| raspi in ~/pods/p42_wordpress ]$
Enter fullscreen mode Exit fullscreen mode

3. Build and Push to your Local Registry

Now, let's build the image and store it in the local registry

[|=| raspi in ~/pods/p42_wordpress ]$ podman build -t localhost:5000/p42_wordpress:v1 .
STEP 1/2: FROM docker.io/library/wordpress:latest
STEP 2/2: RUN echo 'file_uploads = On\nmemory_limit = 256M\nupload_max_filesize = 64M\npost_max_size = 64M\nmax_execution_time = 300' > /usr/local/etc/php/conf.d/uploads.ini
COMMIT localhost:5000/p42_wordpress:v1
--> 6213e109406f
Successfully tagged localhost:5000/p42_wordpress:v1
6213e109406f3ce3ac791b8a8b2d57cf3d678b7c4bb8ede40be427c149b86b18

[|=| raspi in ~/pods/p42_wordpress ]$ podman push localhost:5000/p42_wordpress:v1
Getting image source signatures
Copying blob a0e71ab2b234 done   |
[...]
Copying config 6213e10940 done   |
Writing manifest to image destination

[|=| raspi in ~/pods/p42_wordpress ]$
Enter fullscreen mode Exit fullscreen mode

We can check the local registry by using the following:

[|=| raspi in ~/pods/p42_wordpress ]$ curl http://localhost:5000/v2/_catalog
{"repositories":["p42_wordpress"]}

[|=| raspi in ~/pods/p42_wordpress ]$
Enter fullscreen mode Exit fullscreen mode

Top comments (0)