Kubernetes
Podman

Podman: Setup and Usage Guide

Podman is a daemonless container engine that allows users to run, manage, and orchestrate containers and pods without requiring root privileges. It is a drop-in replacement for Docker and supports docker-compose functionalities using podman-compose.


Installation

Install Podman on Linux

Ubuntu/Debian

sudo apt update -y
sudo apt install -y podman

RHEL/CentOS

sudo yum install -y podman

Fedora

sudo dnf install -y podman

Arch Linux

sudo pacman -S podman

Windows (via WSL2)

  1. Install WSL2 and a Linux distribution (Ubuntu recommended).
  2. Inside WSL, install Podman using the Linux-specific commands above.

macOS

brew install podman

Verifying Installation

Run the following command to check if Podman is installed:

podman --version

To verify Podman’s functionality:

podman info

Running Containers with Podman

Running a Basic Container

podman run --rm -it alpine sh

Running a Container in Detached Mode

podman run -d --name my_container nginx

Listing Running Containers

podman ps

To list all containers (including stopped ones):

podman ps -a

Stopping and Removing Containers

podman stop my_container
podman rm my_container

Pulling Images

podman pull ubuntu

Building an Image from a Dockerfile

podman build -t my_image .

Tagging and Pushing an Image

podman tag my_image docker.io/username/my_image
podman push docker.io/username/my_image

Podman Compose (Running Multi-Container Applications)

Podman provides podman-compose, which is an alternative to docker-compose for running multi-container applications.

Installing podman-compose

Ubuntu/Debian

sudo apt install -y podman-compose

Fedora/CentOS/RHEL

sudo dnf install -y podman-compose

macOS

brew install podman-compose

Using podman-compose

Create a podman-compose.yml file:

version: '3'
services:
  web:
    image: nginx
    ports:
      - "8080:80"
  db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: example

Run the multi-container setup:

podman-compose up -d

To stop and remove containers:

podman-compose down

Additional Podman Commands

Creating and Managing Pods

podman pod create --name mypod -p 8080:80

Add a container to a pod:

podman run -dt --pod mypod nginx

List running pods:

podman pod ps

Inspecting Containers and Pods

podman inspect my_container
podman pod inspect mypod

Generating a Kubernetes YAML from a Pod

podman generate kube mypod > mypod.yaml

Conclusion

Podman is a powerful alternative to Docker that allows for rootless container management. By using podman-compose, users can run multi-container applications efficiently. Whether you are running a single container or orchestrating multiple services, Podman provides a secure and efficient workflow.


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!