learn by doing

Running containers with Podman

In this post I’ll document how to build and run containers with Podman. Podman is a tool which allows you managing OCI containers without the need for a daemon. It aims to provide parity with the docker cli options making it easy for users to transition to using this new tool. You can read more about the Podman motivation in this detailed article.


I ran the steps below on a Fedora 29 system and used an nginx container for this exercise.

## Install podman package
sudo dnf install -y podman

## Create a dockerfile and example conf

cat >> Dockerfile << EOF
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

cat >> nginx.conf << EOF
 events {
     worker_connections  1024;

 http {

 upstream test {

 server {
   listen 80;
   location / {
     proxy_pass http://test;


## Build image
podman build -t nginx .

## List local images
podman images
REPOSITORY                TAG      IMAGE ID       CREATED          SIZE
localhost/nginx           latest   15b6754f2c6a   20 seconds ago   113 MB
<none>                    <none>   f0d066b2080f   21 seconds ago   113 MB   latest   f09fe80eb0e7   2 days ago       113 MB

## Run container
podman run -d --name nginx -p 80:80 -t localhost/nginx

## List running containers
podman ps
CONTAINER ID  IMAGE                   COMMAND               CREATED        STATUS            PORTS  NAMES
6744d22d25e7  localhost/nginx:latest  nginx -g daemon o...  3 seconds ago  Up 3 seconds ago         nginx

As you can notice the user experience remains pretty much the same as with the docker cli. One of the differences in terms of operational experience is how the containers start at boot time. Since there’s no daemon involved in managing the containers we have to rely on systemd and create unit files for each container to automatically start at boot:

## Create systemd unit file
cat >> /etc/systemd/system/nginx.service << EOF
Description=Nginx Podman container
ExecStart=/usr/bin/podman start -a nginx
ExecStop=/usr/bin/podman stop -t 10 nginx

## Reload systemd config
systemctl daemon-reload

## Enable and start nginx service
systemctl --now enable nginx
Created symlink /etc/systemd/system/ → /etc/systemd/system/nginx.service.

## Check the nginx service status
systemctl status nginx
● nginx.service - Nginx Podman container
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-02-09 02:52:00 UTC; 4s ago
 Main PID: 9259 (podman)
    Tasks: 8 (limit: 2359)
   Memory: 7.2M
   CGroup: /system.slice/nginx.service
           └─9259 /usr/bin/podman start -a nginx

Feb 09 02:52:00 test.novalocal systemd[1]: Started Nginx Podman container.
comments powered by Disqus