Podman, also known as “Pod Manager,” is an open-source tool used for creating and managing containers. It offers a simple and lightweight container runtime environment that is compatible with Docker. With the recent changes in the Docker License, Podman has emerged as a viable alternative for managing containers in most Linux systems.
In this tutorial, we will guide you through the process of installing and using Podman on your Ubuntu 22.04 server. We will cover the prerequisites, installation steps, configuration of the Podman registry, downloading container images, and creating and managing containers with Podman.
Prerequisites
Before we begin, make sure you have the following prerequisites:
- A server running Ubuntu 22.04.
- A root password configured on the server.
Installation
The Podman package is included in the default Ubuntu repository, making the installation process straightforward. Open your terminal and run the following command to install Podman:
apt install podman -y
Once the installation is complete, you can verify the installation by running the following command:
podman -v
You should see the Podman version displayed in the output, confirming that Podman is successfully installed on your Ubuntu 22.04 server.
Configuring the Podman Registry
By default, the Podman registry is not configured to download and install container images from the web. To enable this functionality, you need to configure the Podman registry.
Open the /etc/containers/registries.conf
file using a text editor:
nano /etc/containers/registries.conf
Add the following lines to the file:
[registries.search] registries=["registry.access.redhat.com","registry.fedoraproject.org","docker.io"]
Save and close the file.
Downloading Images with Podman
With Podman, you can easily search for and download container images from the web. To search for a Debian image, use the following command:
podman search debian
This command will display a list of available Debian images. Each image entry includes information such as the image name, description, stars, and whether it is official or automated. Choose the desired image based on your requirements.
To download the latest Debian image, use the following command:
podman pull debian
This command will download the latest Debian image to your system. You can verify the downloaded image by running the following command:
podman images
This command will display a list of all the images available on your system, including the recently downloaded Debian image.
Creating and Managing Containers with Podman
Now that you have downloaded an image, you can use Podman to create and manage containers.
To create a container from the Debian image, use the following command:
podman run-dit --name debian-container debian
This command will create a new container named “debian-container” based on the downloaded Debian image.
To see the running containers, use the following command:
podman ps
This command will display the running containers on your system, including the newly created Debian container.
To connect to the Debian container, use the following command:
podman attach debian-container
This command will connect you to the shell inside the container, allowing you to execute commands and perform operations within the container environment.
To exit from the container, use the exit
command.
To stop the container, use the following command:
podman stop debian-container
To start the container again, use the following command:
podman start debian-container
To delete the container, use the following command:
podman rm debian-container
To delete the Debian image, use the following command:
podman rmi debian
Conclusion
Congratulations! You have successfully installed and used Podman on your Ubuntu 22.04 server. Podman provides a lightweight and efficient alternative to Docker for managing containers in Linux systems. By following the steps outlined in this tutorial, you can leverage Podman’s features to create and manage containers effectively.
For more information about Podman and its capabilities, refer to the official Podman documentation. If you require reliable and scalable cloud hosting solutions, consider exploring the services offered by Shape.host, a trusted provider of Cloud VPS services.