Open In App

How to create a container using Podman?

Last Updated : 21 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The emergence of Podman as a powerful engine for containers without daemons has presented a very good alternative to Docker. Always having your Podman installation up to date means that you will have the latest features, bug fixes, and security enhancements. This guide will take you through the steps of updating Podman on different Linux distributions.

What is Podman and how does it work?

Podman, which stands for "Pod Manager " is a command line tool that lets you create, operate, and oversee containers based on the Open Container Initiative (OCI) standards. It follows a command format to Docker allowing users familiar, with Docker to easily transition to Podman. Podman functions, by engaging with the container runtime the OS kernel, and image repositories. Unlike Docker, which depends on a background daemon process Podman doesn't need a daemon to run making it lighter and more secure.

Explanation Of Podman With Its Terminologies

  • OCI (Open Container Initiative): Standardized units of software that package an application and its dependencies for consistent execution across environments.
  • Container Image: A read-only template used to create containers, containing the application's filesystem, runtime, and configuration.
  • Podman: A daemonless container engine that allows users to build, manage, and run OCI containers directly as processes.
  • Rootless Containers: Containers that run without elevated (root) privileges, enhancing security.
  • Container: A lightweight, standalone executable package that includes everything needed to run an application (code, runtime, libraries, system tools, settings).

Getting Started with Podman

Step 1: Installation: Podman is typically available in your Linux distribution's package manager. For example, on Ubuntu, use.

sudo apt-get install podman
Install podman


Step 2: Pulling an Image: To use a container, you need its image. Pull images from a container registry like Docker Hub.

podman pull ubuntu:latest
podman pull ubuntu:latest

Step 3: Creating a Container.

podman create --name my-ubuntu-container ubuntu:latest

Step 4: Starting the Container.

podman start my-ubuntu-container

Step 5: Running Commands Inside the Container.

podman exec -it my-ubuntu-container bash

This launches an interactive Bash shell inside the container.

Hands-On Example: NGINX Web Server

Let's create a simple NGINX web server container:

Step 1: Pull the Image:

podman pull docker.io/library/nginx:latest
podman pull docker.io/library/nginx:latest

Step 2: Create and Run the Container.

podman run -d --name my-nginx -p 8080:80 docker.io/library/nginx:latest
podman run -d

This command does the following:

  • Runs the container in detached mode (-d)
  • Names it my-nginx
  • Maps port 8080 on your host to port 80 in the container

Step 3: Verify: Open your web browser and navigate to http://localhost:8080. You should see the default NGINX welcome page.

Nginx

Can I use Docker images with Podman?

Yes! Podman is fully compatible with OCI-compliant images, including those from Docker Hub.

How does Podman work without a daemon?

Podman uses a fork/exec model, launching containers directly as child processes of the Podman process.

Is Podman suitable for production environments?

Absolutely. Podman is a robust and reliable container engine used in various production setups.

How do I create my own container images?

You can use tools like Buildah or Dockerfiles (which are also compatible with Podman) to create custom container images.





Next Article
Article Tags :

Similar Reads