Podman - Short command guide - Part 4
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.
This command is for pulling various images from a repository and putting them locally.
The format as below can also be used if desired.
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 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.
Starts the container in a detached process, needed for containers that we want to be running constantly, only for the
create do not use this.
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
udp, it can even be a range of ports, like this
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.
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.
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.
Gets a list of running containers with status, uptime and so on.
this option makes it list all containers, not just the ones running but all the exists on the server.
To see the pod a container is connected to, a pod can contain one or more containers.
Displays the total size of a container.
When looking for specific containers based on their status, name and so on, you can narrow it down with this parameter.
Formats the output the way you want it.
Prints the log for the specified container, it can be either
container id or the name of the container.
This will print out the log and continue to follow it and print every log entry until stopped with
This tells the log output to only print entries from that timeframe 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.
Tells the log to only print up to designated time, in conjunction with
--since you can filter to only show logs for a certain timespan, god for investigating errors and when the log is big, here same applies regarding time format as for
Outputs timestamps along with the log information, good when trying to find when something happened.
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.
Managing containers within your ecosystem
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.
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.
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.
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.
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 a container and outputs it as a JSON formatted text and can be filtered, use the
--help for more options.
With this you manage your pods and can
restart your pods and more, pods are a collection of containers and we will look more on this in part 7.
podman pod startor
podman container startto limit it's search for what to start even tho you cannot have a pod or container with the same name.
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.
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.
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