Installation#

$ dnf install -y podman podman-plugins

Authentication#

$ podman login quay.io

Images#

To list images:

$ podman images

To pull an image:

$ podman pull <repo>/<name>:<tag>

For example, to pull Fedora image:

$ podman pull fedora:<version>

To pull PostgreSQL image:

$ podman pull postgres

To pull PKI ACME image:

$ podman pull quay.io/dogtagpki/pki-acme:latest

To remove all unused images:

$ podman image prune --all -f

To remove all images:

$ podman rmi -a -f

Containers#

To list containers:

$ podman ps

To run a new container:

$ podman run --name <container> --rm -it <image>

To run a command in a new container:

$ podman run --rm -it <image> <command>

To run a shell in a new container:

$ podman run --rm -it <image> /bin/bash

To access an existing container:

$ podman exec -it <container> <command>

To run a shell in an existing container:

$ podman exec -it <container> sh

To remove a container:

$ podman rm -f <container>

To remove all stopped containers:

$ podman container prune -f

Networking#

To list networks:

$ podman network ls

To create a network:

$ podman network create example
/etc/cni/net.d/example.conflist

Edit /etc/cni/net.d/example.conflist as follows:

{
   "cniVersion": "0.4.0",
   "name": "example",
   "plugins": [
      ...
      {
         "type": "dnsname",
         "domainName": "example.com"
      }
   ]
}

To attach containers:

$ podman network connect <network> <container>

To get container’s IP address:

$ podman inspect -f '{{ .NetworkSettings.Networks.<network>.IPAddress }}' <container>

Building an Image#

$ podman build \
    -t <name> \
    --build-arg <arg>=<value> \
    <dir>

Tagging an Image#

To tag an image:

$ podman tag <name>:<tag> <new name>:<new tag>

For example:

$ podman tag pki-acme:latest quay.io/dogtagpki/pki-acme:latest

Pushing an Image#

To push an image:

$ podman push <repo>/<name>:<tag>

For example:

$ podman push quay.io/dogtagpki/pki-acme:latest

Pods#

To list pods:

$ podman pod list

To create a pod:

$ podman pod create --name acme

To remove a pod:

$ podman pod rm -f <pod>

See Also#