Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Essential Podman commands

32 min read
Improve this page

Logo Podman

You started a container and podman ps shows nothing. Or a podman run command stops on a name or port error that you do not understand. These situations almost always come from three things: a container lives only as long as its process, a stopped container still exists, and a low port is forbidden to an ordinary user.

This page teaches the basic podman commands on a throwaway image, with the output of each step. To understand why Podman has no central service and what rootless means, see the core concepts (in French). What comes after: volumes (in French), networks (in French), advanced options of run (in French), pods (in French), Quadlet (in French) and building images (in French).

What you will learn

  • Download an image and refer to it by its full name
  • Run a container in the foreground, in the background or as a throwaway, with --name, -d and --rm
  • List containers, read their logs, run a command inside one, read a field with inspect --format
  • Stop, restart and remove a container, and read the exit codes 125, 126 and 127
  • Publish a port and mount a folder in rootless mode, knowing the limits

Prerequisites

You know how to open a terminal, create a folder with mkdir and move around with cd. Podman is installed (installation, in French) and the podman --version command answers. curl is used in the section on ports and in exercise 2. No root right is needed: everything runs under your own account.

Create the practice folder

One folder and one variable are enough for the whole page. The IMG variable holds the busybox image pinned by its digest (@sha256:…): the digest guarantees that you run exactly the same image as on the page, even if the 1.37 tag is published again. data/f.txt is used in the section on volumes. Before you start, podman images shows the images you already have: the final cleanup removes only the ones this page downloads.

Terminal window
podman images
mkdir ~/podman-lab && cd ~/podman-lab
mkdir data && printf 'hello\n' > data/f.txt
IMG=docker.io/library/busybox:1.37@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec

mkdir stops if the folder already exists. The IMG variable lives in the current terminal: if you open another one, retype the last line. Every container you name carries the cmd- prefix (cmd-web, cmd-actif…), which lets you find and remove them without touching your own. If podman ps -a --filter 'name=^cmd-' already lists some, pick another prefix.

The outputs come from Debian 13 with Podman 5.4.2. When AlmaLinux 10.3 (Podman 6.1.4) answers differently, the difference is pointed out. The latest stable version of Podman is 6.2.1, published on November 24, 2026; the commands on this page have not been tested on it. The names that Podman invents (tender_lewin further down) and the identifiers will be different on your machine. The warning lines about the systemd session, described in the troubleshooting section, are left out of the outputs.

The podman command in detail

podman reads from left to right: the program, the action, the options of that action, the image, then the command to run inside the container. Each piece of the line below is explained, with the result of the complete line.

Anatomy of the command

Syntaxpodman run [options] image [command]

  1. podman the programIt manages images and containers, without a central service.
  2. run the actionCreate a container and start it.
  3. --rm the cleanupoptionalRemove the container when it ends.
  4. --name cmd-essai the nameoptionalTo refer to it later.
  5. $IMG the imageHere in a variable, pinned by its digest.
  6. echo bonjour the commandoptionalReplaces the one set by the image.

Outputbonjour

Full syntax

The form is podman run [options] image [command]. Everything written before the image is read by Podman; everything written after is passed to the container, as arguments of the command. An option placed after the image is therefore no longer a Podman option: --rm is taken for the program to run in the container. The "Exit codes" section shows the error you get.

How podman run creates a container, step by step

Predict before you look at the map. After podman run --rm --name cmd-essai $IMG echo bonjour, what does the list of containers contain? What happens to the output bonjour when you add -d? What happens if you run the command twice without --rm and with the same --name? Then tick -d and --rm in the options, move forward step by step and watch the screen on the right.

Mental model

What podman run does with a container

create the containerrun its processthe process ends, the container stops a container lives as long as its process

$ podman run --name cmd-essai $IMG echo bonjour; podman ps -a --format '{{.Names}} {{.State}}'

  1. Podman creates the cmd-essai container from the busybox image. It does not start yet.
  2. The echo process starts and writes bonjour. Its output reaches your screen.
  3. echo has nothing left to do: it ends with code 0, and the container stops with it.
  4. The container is stopped but still exists. Its name is taken: a second run --name cmd-essai would fail.

What the animation shows

  1. One process, one life: when it ends, the container stops.
  2. Stopped is not removed: podman ps -a still shows it.
  3. `-d` hides the output, podman logs finds it again.
  4. `--rm` removes everything at the end, logs included.

Golden rules

Name your containers

Without --name, podman makes up a name:

podman run -d --name cmd-web $IMG sleep 3600

Look at the stopped ones too

ps alone shows only those running:

podman ps -a

Essential vocabulary

Run · a container

run
See the outputpodman run --name cmd-essai $IMG echo bonjour → bonjour
--rm
Keep nothingpodman run --rm $IMG true; podman ps -a --format '{{.Names}} {{.State}}' → no container
--name
The name already takenpodman run --name cmd-essai $IMG true; podman run --name cmd-essai $IMG true 2> /dev/null; echo $? → code 125
$?
The command that failspodman run --rm $IMG false; echo $? → code 1

Follow · and clean up

logs
The output of a containerpodman run -d --name cmd-essai $IMG echo bonjour > /dev/null; sleep 1; podman logs cmd-essai → bonjour
exec
Enter a containerpodman run -d --name cmd-web $IMG sleep 3600 > /dev/null; podman exec cmd-web echo ok → ok
rm
Remove a running containerpodman run -d --name cmd-web $IMG sleep 3600 > /dev/null; podman rm cmd-web 2> /dev/null; echo $? → code 2
stop
Stop, then the statepodman run -d --name cmd-web $IMG sleep 3600 > /dev/null; podman stop -t 1 cmd-web > /dev/null 2>&1; podman ps -a --format '{{.Names}} {{.State}}' → exited

Download an image

podman pull downloads an image into your local storage, without running anything. The full name reads registry/namespace/image:tag: here docker.io is the registry, library the namespace of official images, busybox the image and 1.37 the tag. After the tag, @sha256:… pins the exact image.

Terminal window
podman pull $IMG
podman images
Output, Debian 13 (Podman 5.4.2)
Trying to pull docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec...
[...]
30ecbe1509090b38ef3260f3609d64d8261230464eaa4d235901db496e9647fb
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox <none> 30ecbe150909 2 years ago 4.67 MB

Look at the first line of pull: the 1.37 tag has disappeared, only the name and the digest remain. When a name carries both a tag and a digest, Podman drops the tag and stores the image as name@sha256:…. The next line is the image identifier. podman images therefore shows <none> in TAG.

A short name works too, but check what it downloads:

Terminal window
podman run --rm busybox echo court # ❌ image not pinned
Output, Debian 13 (Podman 5.4.2)
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
[...]
court

Podman found busybox in an alias file and downloaded latest, a different image from the one on this page, with no error. Always write the full name with a tag or the digest. An unknown short name stops with code 125:

Terminal window
podman run --rm zzz-inexistant echo x
Output, Debian 13 (Podman 5.4.2)
Error: short-name "zzz-inexistant" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"

On AlmaLinux (Podman 6.1.4), run without a terminal, the message is Error: short-name resolution enforced but cannot prompt without a TTY, with the same code. In a terminal, it shows instead a Please select an image: menu that offers registry.access.redhat.com/zzz-inexistant:latest, registry.redhat.io/zzz-inexistant:latest and docker.io/library/zzz-inexistant:latest: do not pick any, quit with Ctrl+C.

Run a container

podman run creates a container from an image, starts it and runs the requested command. Without -d, it stays in the foreground and prints the output of the command in your terminal.

Terminal window
podman run $IMG echo bonjour
Output
bonjour

The echo command ends, so the container stops but still exists. It has no name: Podman invents one. --name sets one, --rm removes the container when it ends. To work inside it, -it opens an interactive terminal (-i keeps the input open, -t provides a terminal): with podman run -it --rm $IMG sh, the prompt becomes / #, and exit leaves the shell and, with --rm, removes the container.

List containers

podman ps shows the running containers. podman ps -a adds the stopped ones. Right after the previous echo bonjour, the first command shows only the header:

Terminal window
podman ps
podman ps -a
Outputs, Debian 13 (Podman 5.4.2)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a111cbd9a3c4 docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec echo bonjour Less than a second ago Exited (0) Less than a second ago tender_lewin

Look at the STATUS column: Exited (0) means the process ended with code 0, without error. IMAGE shows the image with its digest, like pull. NAMES shows the invented name: yours will be different, write it down. --format chooses the columns, with a Go template: podman ps -a --format '{{.Names}} {{.Status}}' prints only the name and the status.

Run a container in the background

-d (detach) gives you your terminal back right away. podman run -d prints the full container identifier (64 characters); podman ps shows the beginning of it. The sleep 3600 process lasts one hour, which leaves you time to work on it.

Terminal window
podman run -d --name cmd-web $IMG sleep 3600
podman ps
Outputs, Debian 13 (Podman 5.4.2)
55512b17ee714b3c8e68937e32a27ef17173c9c9f099a97d8364118f1fab5d0f
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55512b17ee71 docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec sleep 3600 Less than a second ago Up Less than a second cmd-web

A container that stops immediately

A container lasts as long as its process. Started with -d, a command that ends at once leaves the container stopped, without any message:

Terminal window
podman run -d --name cmd-bavard $IMG echo ligne1

The output is the container identifier, nothing else. ps no longer shows it, ps -a shows it as Exited (0): the container did not fail, its command was already finished.

Read the logs

podman logs reads again what the container's process wrote to its output, even after the container has ended: this is the usual way to recover the output of a container started with -d. With -d --rm, the container disappears when its process ends, and its logs with it.

Terminal window
podman logs cmd-bavard
Output
ligne1

-f follows new lines as they arrive and does not give the terminal back: Ctrl+C interrupts it. So that the example does not block your terminal, timeout 5 cuts the command after 5 seconds, and echo $? then prints the exit code of the previous command: 0 if it succeeded, another number otherwise.

Terminal window
podman run -d --name cmd-tic $IMG sh -c 'for i in 1 2 3; do echo tic$i; sleep 1; done; sleep 3600'
timeout 5 podman logs -f cmd-tic; echo $?
Output, Debian 13 (Podman 5.4.2), 124 is the code of timeout, which cut the follow
tic1
tic2
tic3
124

Run a command in a container

podman exec runs a command inside a container that is already running, without creating a new one. The container must be running.

Terminal window
podman exec cmd-web hostname
Output
55512b17ee71

Compare this host name with the identifier that ps shows for cmd-web. Yours will be different.

Control the container lifecycle

A container is running, stopped or removed, and each command in this section moves it from one state to another. Look at the middle state: a stopped container stays on disk with its name, podman start restarts it, and only podman rm removes it.

Four states: the image becomes a running container with podman run -d. The end of the process or podman stop makes it stopped, and podman start restarts it. podman rm removes a stopped container, podman rm -f removes a running container directly.podman run -dprocess endsor podman stoppodman startpodman rmpodman rm -fImagerunningprocess runningstoppedkept, name takenremovedname free again
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

podman stop asks the process to stop (the SIGTERM signal), waits 10 seconds by default, then kills it (SIGKILL). Your sleep did not react to the first signal: a process started directly in a container is process number 1 there, which the kernel treats differently (see advanced podman run, in French).

Terminal window
time podman stop cmd-web
podman stop cmd-bavard
podman ps -a
Outputs, Debian 13 (Podman 5.4.2)
time="2026-11-25T17:00:27Z" level=warning msg="StopSignal SIGTERM failed to stop container cmd-web in 10 seconds, resorting to SIGKILL"
cmd-web
real 0m10.151s
cmd-bavard
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[...]
55512b17ee71 docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec sleep 3600 16 seconds ago Exited (137) Less than a second ago cmd-web
[...]

The warning says that SIGTERM was not enough and that Podman moved on to SIGKILL, hence the 10 seconds of real. Under zsh, time prints a single line and the duration is labelled total. The Exited (137) status is the trace of it: a process killed by SIGKILL ends with 137, which is 128 plus the signal number 9. -t 1 shortens the wait to one second. podman kill sends SIGKILL directly: tested on a sleep container, it gave the terminal back in 0.1 seconds and the status was also Exited (137).

podman exec refuses a stopped container, and its exit code is not 0:

Terminal window
podman exec cmd-web hostname; echo $?
Output, Debian 13 (Podman 5.4.2)
Error: can only create exec sessions on running containers: container state improper
255

podman start restarts a stopped container with the files it had written: it is not recreated from the image.

Terminal window
podman start cmd-web
podman exec cmd-web sh -c 'echo gardé > /tmp/k'
podman stop -t 1 cmd-web
podman start cmd-web
podman exec cmd-web cat /tmp/k
podman stop -t 1 cmd-web
Output, Debian 13 (Podman 5.4.2)
cmd-web
[...]
gardé
[...]

The /tmp/k file written before the first stop is still there after the second start.

A stopped container still exists. podman rm removes it, and accepts several names: podman rm cmd-bavard cmd-web removes them in one go and prints their names. Removing a running container is refused. Create cmd-actif, then try:

Terminal window
podman run -d --name cmd-actif $IMG sleep 3600
podman rm cmd-actif; echo $?
Output, Debian 13 (Podman 5.4.2), after the identifier printed by run
Error: cannot remove container 8998738e4b70963d7cce164424a2e9367250cf008fc6db57adb37fb5742ae7c7 as it is running - running or paused containers cannot be removed without force: container state improper
2

The message says what to do: stop first (podman stop), or force with podman rm -f, which stops then removes. The exit code is 2. An image used by a container, even a stopped one, cannot be removed either: podman rmi $IMG answers image is in use by a container with code 2. Remove the containers first.

Container name already in use

A name stays taken as long as the container is not removed, whether it runs or not. cmd-actif still exists, so:

Terminal window
podman run --name cmd-actif $IMG true; echo $?
Output, Debian 13 (Podman 5.4.2)
Error: creating container storage: the container name "cmd-actif" is already in use by 8998738e4b70963d7cce164424a2e9367250cf008fc6db57adb37fb5742ae7c7. You have to remove that container to be able to reuse that name: that name is already in use, or use --replace to instruct Podman to do so.
125

The message gives both ways out: remove the existing container, or add --replace, which removes the container with the same name before creating the new one, even if it is running. Code 125 is detailed in the "Exit codes" section.

A background container that fails Exercise 1 of 2 · ~8 min · terminal

You start in the background a container named cmd-job whose command is sh -c 'echo avant; exit 3'. podman run -d prints no error, and you want to know what happened.

Run it, then find the failure

Start cmd-job with -d on the image in the IMG variable and print the exit code with echo $?. Then list all containers, note the exit code of cmd-job, and read its logs.

I have tried: show the solution
Terminal window
podman run -d --name cmd-job $IMG sh -c 'echo avant; exit 3'; echo $?
podman ps -a
podman logs cmd-job
Outputs, Debian 13 (Podman 5.4.2)
f96ecea38d3249941172f8a82308cc7fac58b8b0622ef626afa10a1f3b16fa20
0
[...]
f96ecea38d32 docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec sh -c echo avant;... Less than a second ago Exited (3) Less than a second ago cmd-job
avant

podman run -d returns 0: it says that the container started, not that its command succeeded. Code 3 is read in the STATUS column of ps -a, and podman logs shows what the container wrote before it failed. With -d, an error in the container is not displayed: look at ps -a, then logs.

Publish a port

A container has its own network: to reach it from the host, -p host:container publishes a port. The first number is the host's, the second is the container's. httpd -f -p 80 is a small busybox web server that listens on port 80 of the container.

Terminal window
podman run -d --name cmd-p8080 -p 8080:80 $IMG httpd -f -p 80
podman port cmd-p8080
Output of podman port, Debian 13 (Podman 5.4.2)
80/tcp -> 0.0.0.0:8080

Read the arrow: port 80 of the container is reachable on port 8080 of all the host's addresses (0.0.0.0). Test the server from the host with curl (-i prints the response header, head -1 keeps only its first line):

Terminal window
curl -s -i http://localhost:8080 | head -1
Output, Debian 13 (Podman 5.4.2)
HTTP/1.1 404 Not Found

The 404 comes from the busybox server, which has no page to serve: the container holds no file at the requested address. This code proves that port 8080 of the host does reach the container's server.

To open the port only to the local machine, add the address: -p 127.0.0.1:8082:80. A port already taken by another container makes the start fail.

Terminal window
podman run -d --name cmd-local -p 127.0.0.1:8082:80 $IMG httpd -f -p 80
podman port cmd-local
podman run -d --name cmd-doublon -p 8080:80 $IMG httpd -f -p 80; echo $?
Outputs, Debian 13 (Podman 5.4.2)
80/tcp -> 127.0.0.1:8082
Error: pasta failed with exit code 1:
Failed to bind port 8080 (Address already in use) for option '-t 8080-8080:80-80'
126

On AlmaLinux (Podman 6.1.4), the message is Listen failed for HOST TCP port */8080: Address already in use then Couldn't listen on requested ports, with the same code 126.

Privileged ports in rootless mode

On Linux, an unprivileged account cannot listen on ports below 1024: the threshold is set by net.ipv4.ip_unprivileged_port_start, which is 1024 by default. In rootless mode, podman runs under your account: publishing port 80 of the host is refused.

Terminal window
podman run -d --name cmd-p80 -p 80:80 $IMG httpd -f -p 80; echo $?
Output, Debian 13 (Podman 5.4.2)
Error: pasta failed with exit code 1:
Failed to bind port 80 (Permission denied) for option '-t 80-80:80-80'
126

On AlmaLinux (Podman 6.1.4), the message is Listen failed for HOST TCP port */80: Permission denied then Couldn't listen on requested ports, with the same code 126. pasta is the component that connects the container's network to the host's in rootless mode. Publish a port greater than or equal to 1024 (-p 8080:80): the container still listens on port 80 inside, only the host's port changes. The page on Podman networks (in French) details pasta and what you can configure.

Inspect a container

podman inspect prints everything Podman knows about a container, as JSON. --format keeps only the requested fields, with a Go template. First create a container that fails, in the foreground this time:

Terminal window
podman run --name cmd-sortie $IMG false; echo $?
podman inspect --format '{{.State.Status}} {{.State.ExitCode}}' cmd-sortie
Outputs, Debian 13 (Podman 5.4.2)
1
exited 1

The first 1 is the exit code of podman run: in the foreground, it repeats the code of the container's command (false returns 1). inspect finds it again in .State.ExitCode, with the state in .State.Status. Now read the IP address, the image and the process number of cmd-p8080:

Terminal window
podman inspect --format '{{.NetworkSettings.IPAddress}}|{{.Config.Image}}|{{.State.Pid}}' cmd-p8080
Output, Debian 13 (Podman 5.4.2)
|docker.io/library/busybox@sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec|6220

The first field is empty: for this rootless container, .NetworkSettings.IPAddress gives no address, and you must not count on it to reach a service. Go through the published port, or through a network created for the purpose: after podman network create cmd-net and podman run -d --name cmd-n1 --network cmd-net $IMG sleep 3600, the command podman inspect --format '{{(index .NetworkSettings.Networks "cmd-net").IPAddress}}' cmd-n1 prints 10.89.0.2, whereas .NetworkSettings.IPAddress stays empty even there (Podman networks, in French). The second field shows the image with its digest, without a tag, like ps. The third is the process number on the host; yours will be different.

Rerun on another port Exercise 2 of 2 · ~7 min · terminal

Earlier, publishing port 80 failed with an error message, and you moved on. You now want the service to answer on port 8081, under the same name cmd-p80.

Look at what is left

List all containers with podman ps -a and note the status of cmd-p80.

Make the service answer on 8081

Rerun cmd-p80 publishing port 8081 of the host to port 80 of the container (same image, same httpd -f -p 80 command, in the background), without removing the container by hand. Then query port 8081 with curl -s -o /dev/null -w '%{http_code}\n', which prints only the HTTP code.

I have tried: show the solution
Terminal window
podman ps -a
podman run -d --replace --name cmd-p80 -p 8081:80 $IMG httpd -f -p 80
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8081

In ps -a, the line of cmd-p80 shows the status Created and the port 0.0.0.0:80->80/tcp: Podman created the container before running into port 80, and never started it. Without --replace, the rerun fails: the name is taken, code 125. With --replace, the Created container is replaced, and curl returns 404, the same code as on port 8080. A podman run that fails at startup leaves a Created container: remove it (podman rm) or rerun with --replace.

Exit codes

In the foreground, podman run returns the code of the container's command when that command ran, and its own codes otherwise. With -d, the code only says that the container started: the code of the command is read afterwards in ps -a. The ones that the tests on this page produced:

CodeWhat it saysExample from the page
0 / 1In the foreground, the code of the container's command; with -d, 0 only says that the container startedecho bonjour, false
2Podman refuses the operation: running container, image in usepodman rm cmd-actif, podman rmi $IMG
125Error from podman itself, before running the commandname already taken, unknown short name
126The container was created, but could not start; Podman's documentation also describes it for a command that is present but not executableport 80 refused, port already in use (Debian and AlmaLinux); the container stays Created
127The requested command is not found in the image--rm placed after the image
255exec on a stopped container, a code that Podman's documentation does not describepodman exec cmd-web hostname after the stop

To see a 127, place the --rm option after the image:

Terminal window
podman run --name cmd-mal $IMG --rm echo bonjour; echo $?
Output, Debian 13 (Podman 5.4.2), AlmaLinux 10.3 (Podman 6.1.4) identical
Error: crun: executable file `--rm` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
127

The message says that --rm does not exist as a program in the image. A command that really does not exist, like podman run --rm $IMG commande-inexistante, returns the same message and the same code. Read the error message before the code: the same number can have different causes. Code 126 also exists for a file that is present but not executable:

Terminal window
podman run --rm $IMG /etc/passwd; echo $?
Output, Debian 13 (Podman 5.4.2)
Error: crun: the path `/etc/passwd` exists but it is not executable: Operation not permitted: OCI permission denied
126

Volumes and lost data

The files a container writes in its own file system disappear with it: a container started with --rm is removed along with what it contained, and a new container starts again from the image. The first container below writes a file and reads it back; the second no longer finds it:

Terminal window
podman run --rm $IMG sh -c 'echo ecrit > /tmp/t.txt; cat /tmp/t.txt'
podman run --rm $IMG cat /tmp/t.txt
Outputs, Debian 13 (Podman 5.4.2)
ecrit
cat: can't open '/tmp/t.txt': No such file or directory

To keep data, mount a host folder with -v host-folder:container-folder. If getenforce answers Enforcing on your machine (SELinux active), add :Z at the end of the mount, for example -v ~/podman-lab/data:/data:Z: according to Podman's documentation, this suffix changes the SELinux label of the folder so that a single container can access it (:z to share it between containers). It has not been tried with SELinux active. With the practice folder mounted on /data, the file written by the container also exists on the host:

Terminal window
podman run --rm -v ~/podman-lab/data:/data $IMG sh -c 'echo ecrit > /data/g.txt'
cat ~/podman-lab/data/g.txt
ls -l ~/podman-lab/data
Outputs, Debian 13 (Podman 5.4.2)
ecrit
total 8
-rw-r--r-- 1 ansible ansible 6 Nov 25 17:00 f.txt
-rw-r--r-- 1 ansible ansible 6 Nov 25 17:00 g.txt

Look at the owner of g.txt: it is your account (ansible on the test machine), although the container wrote it as root. Named volumes and their backups are covered in the page Podman volumes (in French).

Permission denied on a volume

In rootless mode, your account appears as root in the container. The other identifiers of the container (1 to 65536) correspond to the range that /etc/subuid reserves for your account: on the test machine, ansible:165536:65536. Your data folder belongs to you, so root can write in it; the container's identifier 1000 is, for the kernel, another account, which has only the "other" rights of the folder (755, read-only). If a non-root user of the container must write in a mounted folder, see the page Podman volumes (in French). To see the refusal without creating an account, run the same write with --user 1000:

Terminal window
podman run --rm --user 1000 -v ~/podman-lab/data:/data $IMG touch /data/x
Output, Debian 13 (Podman 5.4.2), exit code 1
touch: /data/x: Permission denied

Which command should I use?

This page covers the basic operations. For other needs, here is where to go.

NeedCommand or page
Copy a file between the host and a containerpodman cp file container:/path, and podman cp container:/path file the other way
See the memory and CPU of running containerspodman stats --no-stream
Limit memory or CPU, environment variables, health checkadvanced podman run (in French)
Make two containers talk, DNS, portsPodman networks (in French)

Troubleshooting

Start with podman ps -a: the container you are looking for is almost always there, stopped or never started.

SymptomCauseSolution
Failed to bind port 80 (Permission denied), Listen failed for HOST TCP port */80 or Address already in use (code 126)Port below 1024 refused to a normal account, or port already taken; the container stays CreatedPublish a free port from 1024 up: -p 8080:80; podman rm the Created container
cannot remove container … as it is running or image is in use by a container (code 2)Running container, or a container that still uses the imagepodman stop name or podman rm -f name, then remove the image
Permission denied when writing in a mounted folder, while getenforce answers EnforcingThe SELinux label of the folder is not the container'sAdd :Z to the mount: -v folder:/data:Z
Four level=warning lines before the output, often repeated a second time, including The cgroupv2 manager is set to systemd but there is no systemd user session available (seen on Debian 13 and AlmaLinux 10.3 in an SSH session)SSH session without a systemd user sessionOpen a real session, or follow the message: loginctl enable-linger followed by your user number, as root. The lines disappeared once the user session was available

Clean up the practice folder

This page created the containers prefixed with cmd-, a container with a name invented by Podman (the echo bonjour at the start, tender_lewin in the outputs), images and the ~/podman-lab folder. First check what the filter selects, note the invented name in podman ps -a, then remove only those. podman rm -f on a name that does not exist prints no error. The podman network rm cmd-net line is only needed if you created that network in the "Inspect a container" section.

Terminal window
podman ps -a --filter 'name=^cmd-'
podman rm -f $(podman ps -aq --filter 'name=^cmd-')
podman rm -f NOM_INVENTE
podman network rm cmd-net
podman images

The ^cmd- filter keeps only the names that start with cmd-: a container autre-cmd-x stays in place. In the image list, compare with the one you noted at the start, and remove busybox (the latest tag) and the image of $IMG only if they were not there. Reread the name before running rm -r.

Terminal window
podman rmi busybox
podman rmi $IMG
cd ~ && rm -r ~/podman-lab

Key points

  • A container lives as long as its process: podman ps -a finds it again when stopped, podman logs reads its output. Stopped is not removed: the name stays taken until podman rm, and a run that failed at startup leaves a Created container. With -d, a failure is read in ps -a then logs.
  • Options go before the image: placed after it, --rm becomes the command to run and the code is 127.
  • Write the image with its full name and a tag or a digest: a short name can download latest, with no error.
  • stop waits 10 seconds before SIGKILL (code 137); rm refuses a running container, rmi an image in use (code 2).
  • In rootless mode, publish a port from 1024 up. What the container writes outside a volume disappears with it.

Knowledge check

The questions cover the container lifecycle, ports in rootless mode, volumes and reading a failure. The pass mark is 80%.

Knowledge check

Check what you have learned with this interactive quiz

10 questions
5 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer