Skip to content

Podman - Short command guide - Part 4

Difficult Level:
1
2
3
4
5

In this part we will touch a little on some of the sub commands for podman since this is pretty much the only main command that is used when managing our containers and pods, we will cover the most used ones and some caveats around some of them.

I will not list or talk about every parameter for each command, only the most commonly used ones and i will link directly to podmans own information for a full listing.

To see help about every command you can use --help as the last parameter, for example podman --help or podman pull --help and so on.

podman pull

podman pull

This command is for pulling various images from a repository and putting them locally.

The format as below can also be used if desired.

podman image pull

When pulling an image it will always try to get the one with :latest tag and if that is not desired be sure to include the tag you want to pull like i did with Ubuntu.

podman pull docker.io/ubuntu:jammy

Docs@podman: Link

podman run & podman create

podman run
podman create

These two commands is used when we create standalone containers and give them all sort of option during the creation af a container.

The difference between these two is that run will start the container directly after it's creation, while create will not start the container and you have to do it later with podman start. If running standalone containers run work well, but if you are creating containers that are going to be members of a pod you might not always start the container this way, you want to start it via the podman pod command together with all pod members.

--detach

Starts the container in a detached process, needed for containers that we want to be running constantly, only for the run command, create do not use this.

--publish

Assigns ports to the container, without it there is no communication into the container, and for some containers that is fine, but for example, a web server would not be fine with that. When setting what port or ports to listen to, you always set it in this format outside:inside/protocol, for example --publish 8080:80/tcp, protocol is either tcp or udp, it can even be a range of ports, like this --publish 8000-8005:8000-8005/tcp.

The outside port in rootless mode must be higher that 1024 and the inside port and protocol needs to be what the image has been built with.

--name

As the parameter says, it's naming the container so it is easier to find it when managing a lot of containers, if you do not name your container you must find it based on it's container id, and even look at what command that is running in the container, this can be a total mess if name is not used.

--volume

This parameter maps external volumes to internal ones in the container for persistent storage, this is essential for data that should survive container upgrades.

We will talk more about this in part 5.

run@podman: Link - create@podman: Link

podman ps

podman ps

Gets a list of running containers with status, uptime and so on.

--all

this option makes it list all containers, not just the ones running but all the exists on the server.

--pod

To see the pod a container is connected to, a pod can contain one or more containers.

--size

Displays the total size of a container.

--filter

When looking for specific containers based on their status, name and so on, you can narrow it down with this parameter.

--format

Formats the output the way you want it.

ps@podman: Link

podman logs

podman logs

Prints the log for the specified container, it can be either container id or the name of the container.

--follow

This will print out the log and continue to follow it and print every log entry until stopped with CTRL-C

--since

This tells the log output to only print entries from that time frame up till now, the manual says following about the time format that can be used.

Option can be Unix timestamps, date formatted timestamps,
or Go duration strings (e.g. 10m, 1h30m) computed relative
to the client machine’s time. Supported formats for
date formatted time stamps include RFC3339Nano,
RFC3339, 2006-01-02T15:04:05, 2006-01-02T15:04:05.999999999,
2006-01-02Z07:00, and 2006-01-02.

--until

Tells the log to only print up to designated time, in conjunction with --since you can filter to only show logs for a certain time span, god for investigating errors and when the log is big, here same applies regarding time format as for --since.

--timestamps

Outputs timestamps along with the log information, good when trying to find when something happened.

logs@podman: Link

podman attach

podman attach

This one is a bad one, you attach to a container to follow it's output and when you are done your supposed to be able to exit the container and leaving it running with the following commands, CTRL-P followed by CTRL-Q, but this did not work for me, i hade to do a CTRL-C and thus killing the entire container to get out of attached mode.

This can be a version dependency, the latest i had on my Ubuntu 22.04 LTS when writing this was 3.4.4, i know there are newer versions out there, but not in Ubuntu LTS yet.

So use it carefully for now and to read more about the command the link is below to their own documentation.

attach@podman: Link

podman container

podman container

Managing containers within your ecosystem

attach

This is same as podman attach, use with caution, but it's purpose is to attach to a container and see it's output in live mode.

checkpoint

Creates a checkpoint that you can do various thing with, like exporting them, run podman container checkpoint --help to see all the options it has.

start

Starts a container, same as podman start but limited to only containers, use --help to see all options related to it. With the parameter --all you can start all stopped containers, this is a way to start it all up after the podman server has been restarted and you have a lot och containers to start.

stop

Stops a container, same as podman stop but limited to only containers, use --help to see all options related to it. With the parameter --all you can stop all running containers, this is a way to stop it all before restarting the podman server during a maintenance window.

restart

Restarts a container or all containers with the --all parameter, same as podman restart but limited to only containers, simply put, it restarts the container/containers you specify, one thing i have noticed with some containers is that it starts them to quick and i get an error and the container is not started, so i often use stop, wait a few seconds end then do a start instead of restart but only on some of them.

inspect

Inspect a container and outputs it as a JSON formatted text and can be filtered, use the --help for more options.

container@podman: Link

podman pod

podman pod

With this you manage your pods and can create start, stop, restart your pods and more, pods are a collection of containers and we will look more on this in part 7.

pod@podman: Link

podman start

podman start
With this you can start containers or pods in your system, it will search to see if it is a container or pod automatically and if you want to be sure it is either, use podman pod start or podman container start to limit it's search for what to start even tho you cannot have a pod or container with the same name.

start@podman: Link

podman stop

podman stop

With this you can stop containers or pods in your system, it will search to see if it is a container or pod automatically and if you want to be sure it is either, use podman pod stop or podman container stop to limit it's search for what to stop even tho you cannot have a pod or container with the same name.

stop@podman: Link

podman restart

podman restart

With this you can restart containers or pods in your system, it will search to see if it is a container or pod automatically and if you want to be sure it is either, use podman pod restart or podman container restart to limit it's search for what to stop even tho you cannot have a pod or container with the same name.

restart@podman: Link

Recap

Now we touched a little on the most used podman commands and in short what they do, there is a link for each sub command to podmans on documentation with more about each command and their additional parameters, no point in replication their entire documentation onto here since they will update theirs with new info along the way when they release new version, but the commands i have talked about above are standard and will stay pretty much forever.

The whole documentation for podman can be found here: Link