
How To Create Custom Images With Podman
- by Tech Today News
- Posted on March 25, 2023
Jack Wallen walks you through the steps for creating custom images for Podman deployments with the commit command. Podman is a near 1:1 replacement for the Docker container engine. Although they are quite different underneath the hood, on top of it all they are quite similar. One thing they can both do is empower you to build your images to be used for custom container deployments. This means you can pull down an official image and then commit your changes so that image can be re-used for more custom deployments. SEE: Hiring kit: Back-end Developer (TechRepublic Premium) I’m going to show you how this is done by way of the official Ubuntu image that will be pulled down from docker.io. By doing this you can customize the Ubuntu image to your exact specifications and then deploy new containers based on the changed image. To follow along, you’ll need an operating system that supports Podman such as Rocky Linux, AlmaLinux, RHEL or CentOS. The first thing we’ll do is pull the latest Ubuntu image from Docker.io. To do that, log in to your Linux distribution, open a terminal window and issue the command:
Next, we need to deploy a container with our newly pulled image. This can be achieved with:
You should find yourself at the bash prompt of the newly running container. Update apt with:
We’ll now install the NGINX web server with the command:
You can install any other applications you want. For example, if you’ll need to do Java development, install the latest JRE with:
Exit from the running container with the exit command the then commit the changes to the running container with:
Next, we need to locate the ID of the image with:
You should now see an image listed with the
Where ID is the image ID. You can tag the new image with any name you like. Now, when you issue the command podman images, you should see your newly-tagged image listed like this:
If you want to deploy a container based on that new image, the command might look like this:
And that’s all there is to create a custom image for your Podman deployments. Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.What you’ll need to create a custom image with Podman
How to pull the Ubuntu image
podman pull ubuntu:latest
How to deploy and modify a container with the image
podman run -ti --name ubuntu-dev ubuntu:latest
apt-get update
apt-get install nginx -y
apt-get install default-jre -y
How to create your new image
podman commit ubuntu-dev
podman images
podman tag ID ubuntu-dev-base
localhost/ubuntu-dev-base latest 4bdac71c4932 2 minutes ago 563 MB
podman create --name ubuntu-web ubuntu-dev-base
Jack Wallen walks you through the steps for creating custom images for Podman deployments with the commit command. Podman is a near 1:1 replacement for the Docker container engine. Although they are quite different underneath the hood, on top of it all they are quite similar. One thing they can both do is empower you…