1.Introduction
Podman: The Modern Container Management Tool.
What is Podman?
Podman (short for Pod Manager) is an open-source container management tool designed as an alternative to Docker. Unlike Docker, Podman is daemonless, meaning it does not rely on a background service to manage containers. It provides a secure way to run, manage, and deploy containers and pods.
Why Use Podman?
Podman offers several advantages over Docker:
- Daemonless Architecture – No root privileges required.
- Rootless Containers – Improves security by allowing non-root users to manage containers.
- OCI Compatibility – Works with Open Container Initiative (OCI) images.
- Docker CLI Compatibility – Most Docker commands work with Podman.
- Kubernetes Integration – Easily generates Kubernetes YAML files.
2.Installation of Podman
Podman is available for Linux, macOS, and Windows. Below are the installation steps for different operating systems:
For Ubuntu/Debian
1 2 3 |
sudo apt update sudo apt install podman -y |
For CentOS/RHEL
1 |
sudo yum install -y podman |
For macOS (Using Homebrew)
1 |
brew install podman |
For Windows (Using Winget)
link for download podman: https://podman-desktop.io/downloads/windows
After installation, verify Podman by running:
1 |
podman –version |
3.Running Your First Podman Container
Podman follows a similar command structure to Docker. To pull and run a basic container:
1 |
podman run hello-world |
To run an NGINX container:
1 |
podman run -d -p 8080:80 nginx |
Now, visit http://localhost:8080 to see the running NGINX server.
4.Managing Containers with Podman Command:
Listing Containers
- Running containers:
- All containers (including stopped ones):
1 |
podman ps |
1 |
podman ps -a |
Stopping and Removing Containers
1 |
podman stop <container_id> |
1 |
podman rm <container_id> |
Removing an Image
1 |
podman rmi <image_id> |
Checking System Information
1 |
podman info |
5.Podman vs Docker: Key Differences
Feature | Podman | Docker |
---|---|---|
Daemonless | Yes | No |
Rootless Mode | Yes | No |
Uses OCI Images | Yes | Yes |
CLI Compatible | Yes | Yes |
Pod Support | Yes | No |
You can alias Podman to replace Docker commands: alias docker=podman
6.Working with Pods in Podman
Pods in Podman function similarly to Kubernetes pods, allowing multiple containers to share networking and resources.
Creating a Pod
1 |
podman pod create --name mypod -p 8080:80 |
Running a Container Inside a Pod
1 |
podman run -dt --pod mypod nginx |
Listing Pods
1 |
podman pod ps |
Inspecting a Pod
1 |
podman pod inspect mypod |
7.Building and Running Custom Images with Podman
Step 1: Create a Dockerfile.
1 2 3 4 5 |
FROM ubuntu:latest RUN apt update && apt install -y nginx CMD ["nginx", "-g", "daemon off;"] |
Step 2: Build the Image with Podman
1 |
podman build -t my-nginx . |
Step 3: Run the Custom Container
1 |
podman run -d -p 8080:80 my-nginx |
8.Podman and Kubernetes Integration
Podman allows easy conversion of container configurations into Kubernetes YAML manifests.
Generating a Kubernetes YAML File
1 |
podman generate kube mypod > mypod.yaml |
Applying YAML in Kubernetes
1 |
kubectl apply -f mypod.yaml |
9.Running Podman as a Systemd Service
Podman integrates with systemd for automated container management.
Generating a systemd Service for a Podman Container
1 |
podman generate systemd --new --files --name my-nginx |
Enabling and Starting the Service
1 2 3 |
systemctl --user enable container-mypod systemctl --user start container-mypod |
Command | Description |
---|---|
podman –version | Check the installed Podman version |
podman info | Display system information about Podman |
podman –help | Show help for Podman commands |
Command | Description |
---|---|
podman pull <image> | Pull an image from a container registry |
podman images | View all available images |
podman run <image> | Run a container from an image |
podman run -d <image> | Run a container in detached mode |
podman run -it <image> bash | Run a container interactively with a shell |
podman start <container_id> | Start a stopped container |
podman stop <container_id> | Stop a running container |
podman restart <container_id> | Restart a container |
Command | Description |
---|---|
podman rm <container_id> | Remove a container |
podman ps | List running containers |
podman inspect <container_id> | View container details |
podman logs <container_id> | View container logs |
podman exec -it <container_id> /bin/bash | Access a running container’s shell |
podman stats <container_id> | Monitor a container’s resource usage |
Command | Description |
---|---|
podman search <image> | Search for an image in a registry |
podman pull <image> | Download an image from a registry |
podman images | List all downloaded images |
podman rmi <image> | Remove an image |
podman tag <image> <new_image> | Tag an image with a new name |
podman history <image> | Show details about an image |
Command | Description |
---|---|
podman build -t <image> . | Build an image from a Dockerfile |
podman save <image> > <image>.tar | Save an image as a tar file |
podman load -i <image>.tar | Import an image from a tar file |
podman push <image> | Push an image to a remote registry |
Command | Description |
---|---|
podman network ls | List all available networks |
podman network inspect <network> | View network details |
podman network create <network_name> | Create a custom network |
podman network rm <network_name> | Remove a network |
podman run -p <host_port>:<container_port> <image> | Map ports between host and container |
Command | Description |
---|---|
podman pod ls | List all running pods |
podman pod inspect <pod_name> | Show pod details |
podman pod start <pod_name> | Start a stopped pod |
podman pod stop <pod_name> | Stop a running pod |
podman pod rm <pod_name> | Remove a pod |
Command | Description |
---|---|
podman generate kube <container/pod> | Generate a Kubernetes YAML from Podman |
podman kube play <kube>.yaml | Deploy a Kubernetes YAML in Podman |
Command | Description |
---|---|
podman generate systemd –name <container> | Generate a systemd service for a container |
podman user start container <container> | Start the systemd-managed container |
podman user status container <container> | Check the status of the container service |
Command | Description |
---|---|
podman volume create <volume_name> | Create a new volume |
podman volume ls | List all volumes |
podman volume inspect <volume_name> | Show details about a volume |
podman run -v <volume_name>:/path/in/container <image> | Attach a volume to a container |
Command | Description |
---|---|
podman unshare ls | Open a shell in a user namespace (listing the directory as rootless user) |
podman run –userns=keep-id <image> | Run a container with the same user ID as the host |
10. Conculsion
Podman is a secure, daemonless, and rootless container management tool that provides an excellent alternative to Docker. Its Kubernetes integration, pod support, and OCI compatibility make it a powerful choice for containerized applications.
bluethinkinc_blog
2025-04-11