How to create custom images with Podman
Jack Wallen walks you through the steps to create custom images for Podman deployments using the commit command.
Podman is a near 1:1 replacement for the Docker container engine. While they’re quite different under the hood, they’re pretty similar on top of that. One thing both can do is enable you to build your images that will be used for custom container deployments. This means you can get an official image and then commit your changes so the image can be reused for further custom deployments.
SEE: Hire Kit: Backend Developer (TechRepublic Premium)
I’ll show you how to do this using the official Ubuntu image pulled down from docker.io. This allows you to customize the Ubuntu image exactly to your specs and then deploy new containers based on the modified image.
What you need to create a custom image with Podman
To participate, you need an operating system that supports Podman, such as Rocky Linux, AlmaLinux, RHEL, or CentOS.
How to pull the Ubuntu image
First, let’s pull the latest Ubuntu image from Docker.io. To do this, log into your Linux distribution, open a terminal window and enter the command:
podman pull ubuntu:latest
How to deploy and modify a container with the image
Next we need to deploy a container with our newly pulled image. This can be achieved with:
podman run -ti --name ubuntu-dev ubuntu:latest
You should find yourself at the bash prompt of the newly executed container.
Update apt with:
apt-get update
We now install the NGINX web server with the command:
apt-get install nginx -y
You can install any other application. For example, if you need to do some Java development, install the latest JRE with:
apt-get install default-jre -y
How to create your new image
Exit the running container with the exit command and then commit the changes to the running container with:
podman commit ubuntu-dev
Next we need to find the id of the image with:
podman images
You should now see an image labeled
podman tag ID ubuntu-dev-base
Where ID is the image ID.
You can name the new image anything you like. Now when you issue the podman images command, you should see your newly tagged image listed as follows:
localhost/ubuntu-dev-base latest 4bdac71c4932 2 minutes ago 563 MB
If you want to deploy a container based on this new image, the command might look like this:
podman create --name ubuntu-web ubuntu-dev-base
And that’s all you need to create a custom image for your Podman deployments.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for the latest tech advice for business professionals from Jack Wallen.