Jack Wallen walks you through the steps of creating custom images for Podman deployments with the commit command.
Podman almost 1:1 replaces the Docker container engine. While they look quite different under the hood, they’re also quite similar. One thing they both can do is allow you to build your images to use for custom container deployments. This means you can roll out an official image and then commit your changes so that the image can be reused for more custom deployments.
SEE: Recruitment Kit: Back-end Developer (TechRepublic Premium)
I will show you how it is done by means of the official Ubuntu image which will be extracted from docker.io. By doing so, you can customize the Ubuntu image to your exact specifications and then deploy new containers based on the modified image.
What you’ll need to create a custom image with Podman
To follow, you will need an operating system that supports Podman, such as Rocky Linux, AlmaLinux, RHEL or CentOS.
How to extract Ubuntu image
The first thing we will do is pull the latest Ubuntu image from Docker.io. To do this, log in to your Linux distribution, open a terminal window and run 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 end up at the bash prompt for the new running container.
Update apt with:
apt-get update
We will now install the NGINX web server with the command:
apt-get install nginx -y
You can install any other apps you want. For example, if you need to do 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, then commit changes to the running container with:
podman commit ubuntu-dev
Next, we need to locate the image ID with:
podman images
You should now see an image listed with the label
podman tag ID ubuntu-dev-base
Where ID is the image ID.
You can tag the new image with any name you like. Now when you issue the podman images command, you should see your newly tagged image listed like this:
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 there is to creating a custom image for your Podman deployments.
Subscribe to TechRepublic How to make technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.