Trying Podman as a Docker alternative
Before you begin
In this tutorial we’ll learn how to use Podman instead of Docker to manage containers. A Linux machine with Podman is required to follow this tutorial. These are some examples of how to install Podman (more information about its installation here):
# Install Podman Ubuntu 18.04
$ apt-get update
$ apt-get install software-properties-common -y
$ add-apt-repository -y ppa:projectatomic/ppa
$ apt-get install podman -y
# Install Podman Fedora 29/30
$ dnf install podman
Check installed version:
$ podman -v
podman version 1.6.2
$ podman version
Version: 1.6.2
RemoteAPI Version: 1
Go Version: go1.11.13
OS/Arch: linux/amd64
Podman CLI vs Docker CLI
Podman is known by its lightness, not having a daemon like Docker and by using the runC container runtime process. But apart from its lightweight architecture (fewer processes meaning more resources for our containers) we’ve prepared some commands in order to find out if Podman can make our life easier as container administrator.
Podman login
Podman can connect to the same Docker registries like Docker CLI does to pull images. By default is trying Docker Hub
podman login <registry_url>
podman login docker.io # Docker Hub
Finally, podman login
has the option --authfile
allowing to pass a registry auth file as a parameter, useful for example to log in to GCR for example:
podman login --authfile my_secret_auth_file.json gcr.io
Podman ps
Start a couple of containers:
$ podman run -d nginx:alpine
$ podman run -d nginx:alpine
Check their status with a built-in watch:
$ podman ps -w n
# updating results every two seconds
$ podman ps -w 2
And finally sort the results:
$ podman ps --sort <title_name>
$ podman ps --sort created
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
08d139517070 docker.io/library/nginx:alpine nginx -g daemon o... 2 seconds ago Up 2 seconds ago interesting_williams
cf8bed4b6d1a docker.io/library/nginx:alpine nginx -g daemon o... 7 minutes ago Up 7 minutes ago thirsty_chatelet
Podman logs
This command has a handy -l
parameter allowing us to display the logs of the latest container deployed using Podman (without requiring a container name or ID):
podman logs -l
podman logs -l -f # follows log output
Podman stop
Podman command to stop last container:
$ podman stop -l
0189598647d3afef7c63b02d1e9e2980d478a7d0175ee50e2f74cb850b320aab
$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b2f56b56411 docker.io/library/redis:latest redis-server 8 minutes ago Up 6 minutes ago unruffled_chaum
08d139517070 docker.io/library/nginx:alpine nginx -g daemon o... About an hour ago Up About an hour ago interesting_williams
cf8bed4b6d1a docker.io/library/nginx:alpine nginx -g daemon o... 2 hours ago Up 2 hours ago thirsty_chatelet
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0189598647d3 docker.io/library/redis:latest redis-server 6 minutes ago Exited (0) 4 seconds ago wizardly_dewdney
...
Podman command to stop all containers in one single command:
$ podman stop -a
0189598647d3afef7c63b02d1e9e2980d478a7d0175ee50e2f74cb850b320aab
1b2f56b56411510aebcc21191919c5fbd8047fe81bd984ae9a3540cadacdf998
08d139517070b1c3bd915e96855dca16ec155006d26e2a627b4f09b451021a0c
cf8bed4b6d1ae900fdd55c85a9de9a9344896e2377de850d271df2393a806a2d
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0189598647d3 docker.io/library/redis:latest redis-server 7 minutes ago Exited (0) 32 seconds ago wizardly_dewdney
1b2f56b56411 docker.io/library/redis:latest redis-server 8 minutes ago Exited (0) 2 seconds ago unruffled_chaum
08d139517070 docker.io/library/nginx:alpine nginx -g daemon o... About an hour ago Exited (0) 2 seconds ago interesting_williams
cf8bed4b6d1a docker.io/library/nginx:alpine nginx -g daemon o... 2 hours ago Exited (0) 2 seconds ago thirsty_chatelet
Podman rm
Podman command to remove all containers in one single command (running and stopped containers included):
$ podman rm -a -f
0189598647d3afef7c63b02d1e9e2980d478a7d0175ee50e2f74cb850b320aab
1b2f56b56411510aebcc21191919c5fbd8047fe81bd984ae9a3540cadacdf998
08d139517070b1c3bd915e96855dca16ec155006d26e2a627b4f09b451021a0c
cf8bed4b6d1ae900fdd55c85a9de9a9344896e2377de850d271df2393a806a2d
.. and even their volumes:
$ podman rm -a -f -v
This is a very small portion of the capabilities that Podman can do but as a conclusion we can say that it can do almost the tasks that Docker CLI does plus some extra parameters and filtering.
Finally, you should definitely take a look at these books to fuel your Kubernetes knowledge:
DevOps books:
Cloud providers:
DigitalOcean offers affordable pricing for VMs and many other public cloud services. You can sign up for DigitalOcean and receive a $100 free credit using this referral link.