Skip to content

๐Ÿง Podman Cheatsheet

A compact guide to installing, managing, and using Podman, Skopeo, and related container tools on RHEL.


๐Ÿ”ง General Utilities

sudo unshare -u /bin/bash
lsns
skopeo

๐Ÿ› ๏ธ Podman Installation (RHEL)

sudo dnf -y update
sudo dnf module list | grep container-tools
sudo dnf install -y @container-tools

podman version
podman help

๐Ÿงช Test Installation

podman run -it --rm alpine sh

๐Ÿ“ฅ Image Management

podman image ls
podman pull ubuntu
podman pull centos
podman rmi <IMAGE_ID>

๐Ÿ” Skopeo Usage

skopeo inspect docker://opensuse/leap

mkdir nginx
skopeo copy docker://opensuse/leap dir:nginx
tree nginx

๐ŸŒ Container Management

podman run --rm -d -p 8080:80 nginx
curl localhost:8080
podman ps

Container storage paths:

  • User: $HOME/.local/share/containers
  • Root: /var/lib/containers

โš™๏ธ Registry Configuration

File: /etc/containers/registries.conf

unqualified-search-registries = [
  "registry.fedoraproject.org",
  "registry.access.redhat.com",
  "registry.centos.org",
  "docker.io"
]

๐Ÿ“‚ Volume Mounting

podman run --rm -d --name webserver -h web \
  -v /home/harry/web_test:/usr/share/nginx/html \
  -p 8080:80 nginx

๐Ÿงต Systemd Integration

File: /etc/systemd/system/webserver.service

[Unit]
Description=Podman webserver
After=network.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/podman run --rm -d --name webserver -h web \
  -v /home/harry/web_test:/usr/share/nginx/html -p 8080:80 nginx
ExecStop=/usr/bin/podman stop webserver

[Install]
WantedBy=multi-user.target

Enable and start:

systemctl enable webserver
systemctl start webserver

๐Ÿงฉ Pod Management

podman pod create --name webapp -p 8080:80
podman run -dt --pod webapp --name nginx nginx
podman run -dt --pod webapp --name mariadb mariadb
podman pod ps

๐Ÿ› ๏ธ Buildah Reference

๐Ÿ”— Buildah Workshop


๐Ÿ—‚๏ธ YAML Summary

podman:
  install:
    rhel:
      - sudo dnf -y update
      - sudo dnf module list | grep container-tools
      - sudo dnf install -y @container-tools
      - podman version
      - podman help
  test:
    - podman run -it --rm alpine sh
  images:
    show: podman image ls
    pull:
      - podman pull ubuntu
      - podman pull centos
    remove: podman rmi <IMAGE_ID>
  skopeo:
    inspect: skopeo inspect docker://opensuse/leap
    copy:
      - mkdir nginx
      - skopeo copy docker://opensuse/leap dir:nginx
  containers:
    run_nginx: podman run --rm -d -p 8080:80 nginx
    info_path:
      user: $HOME/.local/share/containers
      root: /var/lib/containers
  registries:
    config: /etc/containers/registries.conf
    search_order:
      - registry.fedoraproject.org
      - registry.access.redhat.com
      - registry.centos.org
      - docker.io
  volumes:
    run_webserver: podman run --rm -d --name webserver -h web -v /home/harry/web_test:/usr/share/nginx/html -p 8080:80 nginx
  systemd:
    service_file: /etc/systemd/system/webserver.service
    enable: systemctl enable webserver
    start: systemctl start webserver
  pods:
    create:
      - podman pod create --name webapp -p 8080:80
      - podman run -dt --pod webapp --name nginx nginx
      - podman run -dt --pod webapp --name mariadb mariadb
  buildah:
    reference: http://redhatgov.io/workshops/rhel_8/exercise1.8/

๐Ÿ  HOME ๐Ÿ” Top