We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Publish Container Images to Docker Hub / Image registry with Podman

Learn how to – Publish Container Images to Docker Hub / Image registry with Podman.

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:

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

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:


Your Cart is Empty

Back To Shop