Podman, the POD Manager, is an OCI-compliant container engine developed by Red Hat as a drop-in replacement for Docker. It manages and runs containers, images, and volumes via a command-line interface. While Docker and Podman share similarities, the key difference is that Podman does not require a daemon to execute containers, whereas Docker relies on the Docker Engine daemon. Podman leverages the libpod library to oversee the entire container ecosystem.
This guide will walk you through the installation and usage of Podman on Debian 11.
Prerequisites
- A server running Debian 11.
- A configured root password on the server.
Installing Podman
The Podman package is readily available in the default Debian 11 repository. You can install it with the following command:
apt-get install podman -y
After the installation, verify the Podman version with:
podman --version
The output should display the Podman version:
podman version 3.0.1
For more detailed information about Podman, use this command:
podman info
The output will include details such as architecture, kernel version, and more.
Configuring OCI Registry
Podman uses the file /etc/containers/registries.conf
to pull container images. Edit this configuration file to define your registries:
nano /etc/containers/registries.conf
Add the following content to the file:
[registries.insecure] registries = [ ] # Uncomment to block pull access from specific registries [registries.block] registries = [ ]
Save and close the file after editing.
Using Podman
Here’s how to pull images and run a container with Podman:
To pull a Debian image, execute:
podman pull debian
The output will confirm successful image retrieval:
Resolved "debian" ... Copying blob ... Storing signatures
Verify the downloaded image with:
podman images
The output should list your images:
REPOSITORY ...
To run a container using the Debian image, use:
podman run -dit debian:latest
You will see a container ID as output:
f85c4df5ab787912c984ec820571da7b95b32736ef94ba691d9ab5019c5b5103
List running containers with:
podman ps
The output will display active containers:
CONTAINER ID ...
To inspect a specific container, use:
podman inspect f85c4df5ab78
The command returns detailed container information:
[...]
Check container logs with:
podman logs f85c4df5ab78
To attach to a running container, enter:
podman exec -it f85c4df5ab78 /bin/bash
You will gain shell access inside the container:
root@f85c4df5ab78:/#
Exit the container shell with:
exit
Stopping and Removing Containers
Podman also enables you to manage container lifecycles.
Stop a running container using:
podman stop f85c4df5ab78
Verify stopped containers with:
podman ps -a
Remove a stopped container with:
podman rm f85c4df5ab78
Commands to stop, start, and remove the latest container:
podman stop --latest
podman start --latest
podman rm --latest
Remove all containers:
podman rm -f `podman ps -aq`
Delete an image:
podman rmi 827e5611389a
The output will confirm image removal:
Untagged: ...
Further Steps with Podman
For a comprehensive guide on using Podman to manage images, volumes, and containers, visit: Getting Started with Podman: Manage Images, Containers and Volumes
Conclusion
In this guide, we demonstrated how to install and use Podman on Debian 11. You can now leverage Podman as an effective alternative to Docker for running and managing containers.
Frequently Asked Questions (FAQ)
- Is Podman compatible with Docker?
- Yes, Podman is designed to be a Docker-compatible container engine, allowing similar commands and operations.
- Why doesn’t Podman require a daemon?
- Podman operates in a rootless mode by default and executes processes directly as the user, negating the need for a background daemon.
- Can I run Docker containers using Podman?
- Yes, you can run and manage Docker containers using Podman, thanks to its biological compatibility with Docker images.
- How do I update Podman?
- To update Podman, you can use the package manager
apt
withsudo apt-get update && sudo apt-get upgrade podman
.