Podman is a tool designed for managing containers and pods without requiring a container daemon as common in Docker world. All the containers and Pods are created as child processes of the Podman tool. The Podman’s CLI (podman) is based on the Docker CLI. In this guide we’ll show you how to create and publish/push Docker images to Docker Hub using Podman.

If you want to build a private container registry with podman, check our guide below:

Install Secure Container registry with Podman

Before you begin, ensure you have podman installed in your system. Here are the guides you can refer to:

How To Install Podman on Debian

How To Install Podman on Arch Linux / Manjaro

How To Install Podman on CentOS & Fedora

Install Podman on Ubuntu

How To Install and Use Podman on CentOS 8 / RHEL 8

Create your Docker image. For this I’ll create a simple Node.js Application.

$ mkdir ~/docker-images/demo/
$ cd ~/docker-images/demo/

Here is my app.js file.

$ vim app.js        
const http = require('http');
const os = require('os');

console.log("Node server starting...");

var handler = function(request, response) {
  console.log("Received request from " + request.connection.remoteAddress);
  response.end("You've hit " + os.hostname() + "\n");

var www = http.createServer(handler);

Create Dockerfile.

$ vim Dockerfile 
FROM node
ADD app.js /app.js
ENTRYPOINT ["node", "app.js"]

Build image with a tag.

$ podman build -t docker.io/jmutai/nodejs-demo:v1 .
STEP 1: FROM node
STEP 2: ADD app.js /app.js
STEP 3: ENTRYPOINT ["node", "app.js"]
STEP 4: COMMIT docker.io/jmutai/nodejs-demo:v1

Replace docker.io/jmutai/nodejs-demo:v1 with the tag for your application.

Login to Docker hub

$ podman login docker.io                           
Username: jmutai
Login Succeeded!

Since I had tagged the image at build in format required by Docker Hub, I can just push it.

$ podman push docker.io/jmutai/nodejs-demo:v1

Pulling Docker image from Docker Hub with podman

You can then pull image on other machines by running:

--- Using docker client ---
$ docker pull docker.io/jmutai/nodejs-demo:v1
$ docker pull jmutai/nodejs-demo:v1

--- Using podman ---
$ podman pull docker.io/jmutai/nodejs-demo:v1
$ podman pull jmutai/nodejs-demo:v1

Run a test container:

--- With podman ---
$ podman  run --name nodejs-demo -p 8080:8080 -d docker.io/jmutai/nodejs-demo:v1

--- With Docker ---
$ docker run --name nodejs-demo -p 8080:8080 -d docker.io/jmutai/nodejs-demo:v1

Now try to access your application at http://localhost:8080 (Replace localhost with the hostname or IP of the Docker host if necessary):

$ curl localhost:8080
You've hit d1a669579a39

Confirm container ID to validate the output

$ podman ps                                                                         
CONTAINER ID  IMAGE                            COMMAND  CREATED             STATUS                 PORTS                   NAMES
d1a669579a39  docker.io/jmutai/nodejs-demo:v1           About a minute ago  Up About a minute ago>8080/tcp  nodejs-demo

Clean your environment:

$ podman rm -f d1a669579a39
$ docker rm -f d1a669579a39

Enjoy using Podman to run container images. For more on Podman check:

How To run Docker Containers using Podman and Libpod

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here