- 1 1. Introduction
- 2 2. What is Podman?
- 3 3. Installing Podman on Ubuntu
- 4 4. Using Dockerfile with Podman
- 5 5. Practical Example: Building an Ubuntu-Based Container
- 6 6. Podman Features and Tips
- 7 7. Migrating from Docker to Podman
- 8 8. Frequently Asked Questions (FAQ)
- 8.1 Q1. What are the main differences between Podman and Docker?
- 8.2 Q2. Is there a difference between Dockerfile and Containerfile?
- 8.3 Q3. Can I use Docker Compose files with Podman?
- 8.4 Q4. Is Podman stable on Ubuntu?
- 8.5 Q5. Are there access restrictions in rootless mode?
- 8.6 Q6. Can Podman pull images from Docker Hub?
- 8.7 Q7. Is Podman suitable for production use?
1. Introduction
The Evolution and Growing Significance of Container Technology
In recent years, container technology has rapidly gained importance in the field of application development and operations. In particular, the ability to match development and production environments ensures reproducibility of operations, a key benefit that has won strong support among engineers.
While Docker remains the most widely recognized container platform, Podman has been attracting increasing attention as a modern alternative. Podman offers a nearly identical command-line interface (CLI) to Docker but stands out with its daemonless and lightweight architecture and its support for rootless (non-root) operation.
Why “Podman + Dockerfile + Ubuntu”?
In this article, we’ll explain how to combine Podman, Dockerfile, and Ubuntu for modern container workflows on Linux.
- Ubuntu is a popular Linux distribution used by everyone from beginners to advanced users,
- Dockerfile serves as a blueprint for building container images,
- and Podman is a next-generation tool designed to manage these images flexibly and securely.
With growing security awareness, the approach of using Podman with Dockerfile on Ubuntu is increasingly adopted by both individual developers and enterprise teams.
Purpose and Target Audience
The goal of this article is to provide a clear, step-by-step guide for building practical containers with Podman and Dockerfile on Ubuntu.
This article is intended for readers such as:
- Developers experienced with Docker who are curious about Podman
- Ubuntu users looking for secure container management
- Engineers aiming to incorporate container technologies into their workflow
- Beginners interested in writing Dockerfiles and building with Podman
We’ll cover everything from the basics and troubleshooting tips to key differences with Docker and how to migrate.
2. What is Podman?
Overview of Podman
Podman (Pod Manager) is a next-generation container management tool developed by a community led by Red Hat. Like Docker, it can build, run, and manage OCI-compliant containers, but its design and architecture differ in significant ways.
Podman’s biggest feature is that it does not require a background daemon. This enables lightweight and secure operation. Podman also supports rootless mode, allowing regular users to manage containers without elevated privileges. The CLI is highly compatible with Docker, so most commands are nearly identical.
Key Features of Podman
Here are some notable features of Podman:
Daemonless Architecture
Podman operates without a background daemon (resident process) for container management. This results in efficient use of resources, without unnecessary background processes.
Rootless Support (Non-Privileged Users)
Podman allows regular users to run and manage containers without administrator privileges. This makes it possible to operate containers safely in multi-user or server environments, significantly reducing security risks.
Docker-Compatible CLI
Podman uses nearly the same command structure as Docker. For example, the following Docker commands work almost identically in Podman:
podman build -t myimage .
podman run -it myimage bash
This allows users familiar with Docker to switch seamlessly to Podman.
Pod Feature
Podman adopts the “Pod” concept from Kubernetes, allowing you to manage multiple containers as a single logical unit. This increases compatibility with Kubernetes and enables smooth migration from local to cloud environments.
Compatibility with Ubuntu
Although Podman is widely adopted on Fedora and RHEL-based distributions, it also runs stably on Ubuntu. You can install it from the official repositories, and setup is straightforward. Especially since Ubuntu 20.04 LTS, package maintenance has improved, lowering the barrier for adoption.
3. Installing Podman on Ubuntu
Before You Begin: Pre-Installation Checklist
Before installing Podman on Ubuntu, first check your Ubuntu version. Podman is recommended for Ubuntu 20.04 LTS or later. Older versions may lack required packages in the official repository.
Check your Ubuntu version with the following command:
lsb_release -a
Installation of Podman requires sudo
privileges. Even if you plan to use rootless mode, administrator privileges are needed for the initial installation, so make sure you have them.
Installing Podman (Ubuntu Official Repository)
On Ubuntu 20.04, 22.04, or later, you can install Podman easily with APT:
sudo apt update
sudo apt install -y podman
After installation, check the version to confirm successful setup:
podman --version
How to Get the Latest Version (Official PPA)
The Podman package in the standard Ubuntu repository may not be the newest. If you want the latest features, use the official Personal Package Archive (PPA):
. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt update
sudo apt install -y podman
This gives you access to the latest Podman release, equivalent to Red Hat and Fedora ecosystems.
Basic Podman Functionality Test
After installation, run a quick check:
podman info
This command shows the Podman version, configuration, and supported features such as rootless mode.
Test pulling and running an official Alpine Linux container:
podman run --rm -it alpine sh
If the shell launches successfully, your Podman setup is working correctly.
4. Using Dockerfile with Podman
What is a Dockerfile?
A Dockerfile is a blueprint for building container images. It’s a text file that lists the base image, packages to install, files to copy, and other instructions in sequence.
Container tools like Podman and Docker can automatically create a consistent environment based on this file.
Example instructions:
FROM ubuntu:22.04
RUN apt update && apt install -y curl
COPY ./app.sh /usr/local/bin/app.sh
CMD ["bash", "/usr/local/bin/app.sh"]
This installs packages, copies scripts, and defines what should run by default in the resulting image.
How to Use Dockerfile with Podman
You can build container images from Dockerfiles with Podman, almost exactly as you would with Docker.
1. Prepare the Directory
Set up your files like this:
project/
├── Dockerfile
└── app.sh
app.sh
can be a simple script:
#!/bin/bash
echo "Hello from Podman container!"
Make the script executable:
chmod +x app.sh
2. Build with Podman
With the Dockerfile in your current directory, run:
podman build -t mypodmanapp .
This creates a container image called mypodmanapp
.
3. Check the Build Result
See the created image with:
podman images
4. Run the Container
Start a container from your built image:
podman run --rm mypodmanapp
If everything is set up correctly, you’ll see: Hello from Podman container!
Difference with Containerfile
Podman supports files named Containerfile, which use the same syntax as Dockerfile. This is simply a neutral name, not tied to Docker branding.
The functionality is identical. Whether you name your file Dockerfile
or Containerfile
, Podman will use it:
podman build -f Containerfile -t myimage .
Just specify the filename with the -f
option if needed.
5. Practical Example: Building an Ubuntu-Based Container
Creating a Dockerfile Based on Ubuntu
Let’s walk through building an Ubuntu-based Dockerfile and building and running a container image with Podman step by step.
Here’s a simple Dockerfile
example:
FROM ubuntu:22.04
RUN apt update && \
apt install -y curl && \
apt clean
COPY hello.sh /usr/local/bin/hello.sh
RUN chmod +x /usr/local/bin/hello.sh
CMD ["/usr/local/bin/hello.sh"]
This Dockerfile:
- Uses the official Ubuntu 22.04 image
- Installs the
curl
package - Copies
hello.sh
from the host into the container - Sets
hello.sh
as the default script
Now, create a simple hello.sh
script:
#!/bin/bash
echo "Hello from a Podman container!"
Give it execute permission:
chmod +x hello.sh
Building the Image with Podman
Once your files are ready, build the image with:
podman build -t ubuntu-hello .
The -t ubuntu-hello
flag tags your image; the .
specifies the build directory.
If successful, you’ll see your new image listed with:
podman images
Running and Testing the Image
Run a container from your new image:
podman run --rm ubuntu-hello
Sample output:
Hello from a Podman container!
The --rm
option automatically removes the container after it exits, perfect for testing.
Tip: Interactive Container Access
If you want to work interactively inside the container, use the -it
option to start Bash:
podman run -it ubuntu-hello bash
This gives you a lightweight Ubuntu development environment inside your container.
6. Podman Features and Tips
Podman Strengths: Flexibility & Security
Podman provides greater flexibility and enhanced security while remaining compatible with Docker. Here are some useful features and daily operation tips.
Secure Operations with Rootless Mode
One of Podman’s key strengths is rootless mode, which allows non-root users to run, stop, and manage containers.
For example, you can use Podman without sudo
:
podman run -it ubuntu bash
Operations are limited to the user’s home directory, minimizing risk to the system. This is especially valuable on shared servers or in dev environments.
Integrating with systemd for Auto-Start
Podman can natively integrate with systemd, allowing containers to start automatically as Linux services.
Generate a systemd unit file with:
podman generate systemd --name mycontainer --files --restart-policy=always
This creates a unit file in ~/.config/systemd/user/
. Enable and start with:
systemctl --user daemon-reexec
systemctl --user enable --now container-mycontainer.service
Containers will now restart automatically even after server reboot.
Managing Multiple Containers with podman-compose
In addition to single-container operations, Podman supports multi-container management. Using podman-compose, you can manage complex projects similar to Docker Compose.
Install with pip:
pip install podman-compose
Because it’s compatible with docker-compose.yml
files, migrating projects is easy.
To start services, just run:
podman-compose up -d
Podman allows you to reproduce development environments instantly.
Other Useful Commands and Tips
Cleanup Unused Images & Containers
podman system prune -a
Remove unused files and images to free up storage.
Shell Completion (bash/zsh)
Install Podman’s completion scripts for easier CLI usage:
sudo apt install podman-docker
This enables command completion, similar to Docker, for the podman
command.
7. Migrating from Docker to Podman
Why Migration to Podman Is Trending
While Docker has long been the de facto standard for containers, Podman is gaining popularity for its lighter weight and stronger security. Red Hat Enterprise Linux (RHEL) and Fedora have shifted from Docker to Podman by default, leading many teams to consider migration.
This section covers practical steps and points to consider for migrating from Docker to Podman.
Command Compatibility: Docker vs. Podman
Podman is highly compatible with Docker commands, so you can generally substitute them directly:
Docker | Podman |
---|---|
docker build -t myapp . | podman build -t myapp . |
docker run -it myapp | podman run -it myapp |
docker images | podman images |
docker ps | podman ps |
This seamless CLI compatibility is a major advantage of Podman.
Achieving Full Compatibility with podman-docker
If your scripts or CI/CD pipelines use docker
commands, installing the podman-docker
package allows Podman to serve as a drop-in replacement:
sudo apt install podman-docker
This sets up the docker
command as a symbolic link to Podman:
which docker
# → /usr/bin/docker → podman symlink
You can then run Docker scripts without modification.
Alternative to Docker Compose: podman-compose
If you use Docker Compose for multi-container projects, podman-compose
provides similar functionality.
It is highly compatible but some Compose options may differ (e.g. depends_on
), and event logging or health checks may behave differently. For basic web + DB stacks, migration is generally smooth.
Migrating Images & Volumes
Local Docker images are not visible to Podman by default. You can:
Option 1: Re-pull with Podman
podman pull ubuntu:22.04
Option 2: Export from Docker → Import to Podman
# Export with Docker
docker save myimage > myimage.tar
# Import with Podman
podman load < myimage.tar
This makes Docker-built images available in Podman.
Other Considerations
- Rootless operation: Docker typically runs as root, while Podman is designed for rootless operation by default
- Daemon structure: Podman is daemonless, so process management differs
- Log and data storage locations may differ—check configs during migration
8. Frequently Asked Questions (FAQ)
Q1. What are the main differences between Podman and Docker?
A1. The biggest difference is that Podman is “daemonless” (requires no background process), making it lighter and more secure. Podman also supports rootless mode, letting users manage containers without elevated privileges. CLI compatibility is high, so most commands are the same.
Q2. Is there a difference between Dockerfile and Containerfile?
A2. There is no functional difference. Both are files describing how to build containers, with identical syntax. Some projects prefer “Containerfile” as a neutral name, but you can use either name with Podman.
Q3. Can I use Docker Compose files with Podman?
A3. Podman does not natively support Docker Compose, but you can use podman-compose
(a Python tool) to interpret and run docker-compose.yml
files in a Podman environment.
Some Compose options (depends_on
, etc.) may have limitations, so test complex setups in advance.
Q4. Is Podman stable on Ubuntu?
A4. Yes, Podman runs reliably on Ubuntu 20.04 LTS and newer. It’s available in the official Ubuntu repositories and can be installed with apt
. For the latest version, you can use the official PPA.
Q5. Are there access restrictions in rootless mode?
A5. In rootless mode, certain privileged operations and binding to ports below 1024 are restricted. Port forwarding can work around this. For most use cases, rootless mode is practical and recommended.
Q6. Can Podman pull images from Docker Hub?
A6. Yes, Podman can pull images from Docker Hub by default. Sometimes you may need to specify the full registry path, e.g., docker.io/library/ubuntu
:
podman pull docker.io/library/ubuntu
Podman also supports registries like Quay.io and GitHub Container Registry.
Q7. Is Podman suitable for production use?
A7. Yes, Podman includes Kubernetes-compatible pod concepts and systemd integration for auto-start, making it suitable for production environments—especially where strong security is needed. Podman is now default on Red Hat Enterprise Linux and Fedora, with broad adoption.