
Podman is an open-source tool for managing containers without the need for a background daemon process. It improves the security and reduces resource usage for containerized applications through its daemonless architecture.
This article covers how to install Podman on Ubuntu 20.04 and perform key operations to manage containerized applications.
Before you begin:
Have an Ubuntu 20.04 server.
Create a Container Registry to store your Podman container images. This article uses Vultr Container Registry as an example, but the commands can be adapted to any registry by switching to the appropriate registry-specific variables.
Access the server using SSH as a non-root user with sudo privileges.
Podman is available in the default package repositories on Ubuntu 20.04. Follow the steps below to install Podman on your server using the APT package manager.
Update the server's package index.
Load the system release information.
Add the official Podman repository to your server's apt index.
Import the repository's GPG key.
Update the package index again.
Install Podman.
View the installed Podman version on your server.
Your output should be similar to the one below.
Podman operates with two system services: podman CLI and podman.socket. The podman CLI allows users to interact directly with Podman to manage containers, images, and pods. Meanwhile, podman.socket is a systemd socket file that provides remote API access for managing Podman, making it suitable for remote control and integration with development tools. You can also run Podman as a system service using podman.socket. Follow the steps below to manage and enable the Podman system service on your server.
Enable the Podman service to automatically start at system boot.
Start the Podman service.
Stop the Podman service.
Restart the Podman service.
View the Podman service status and verify that it's running.
Output:
Podman utilizes different image sources to pull container images from registries listed in the /etc/containers/registries.conf file. Follow the steps below to deploy an HTTP server application using the Nginx container image from Docker Hub.
Pull the Nginx container image from Docker Hub.
Output:
List all container images available on the server.
Verify that the Nginx container image is available in your output.
Run a new containerized application using the Nginx image.
List all running Podman container processes.
Output:
Test access to the container using the host port 9090.
Output:
Podman supports custom registries like the Vultr Container Registry to build and store container images. Follow the steps below to create a Python application using FastAPI, build the container image, and push it to your Vultr Container Registry.
Access your Vultr Container Registry's management panel to view the registry's username and API key credentials.
Create a new environment variable to store your Vultr Container Registry name.
Create another environment variable to store the registry username.
Create a environment variable to store the registry's API key.
Log in to your Vultr Container Registry using the environment variable values.
Replace sjc.vultrcr.com with the URL of the region where your VCR is hosted.
Output:
Create a new Python application file app.py.
Add the following contents to the file.
Save and close the file.
The above FastAPI application initializes a new web server on port 5000 that displays a Hello from Vultr message when accessed.
Create a new Dockerfile configuration.
Add the following contents to the file.
Save and close the file.
The above Dockerfile creates a Python 3.12 environment, installs fastapi and uvicorn, and runs a web server on port 5000 using the app.py file.
Build the container image with all files in your working directory.
Output:
Tag the container image with your Vultr Container Registry's name.
Replace sjc.vultrcr.com with the URL of the region where your VCR is hosted.
List all container images on your server and verify that the tagged image is available.
Output:
Push the image to your Vultr Container Registry.
Replace sjc.vultrcr.com with the URL of the region where your VCR is hosted.
Output:
Deploy a new containerized application using your Vultr Container Registry image.
Test access to the application using Curl on the host port 5000.
Output:
You have successfully installed Podman on your Ubuntu 20.04 server and deployed containerized applications. Podman allows you to build, store, and manage containers on your server.
0 Comments
Be the first to comment and share your perspective with the community.