Last Updated on 2024-10-17 by Clay
Introduction
Podman is an open-source tool designed to manage containers and images. Its full name is Pod Manager tool (podman). While Podman is similar to Docker, there are a few key differences in its design.
- Daemonless & Rootless:
Each Podman instance runs as an independent process and does not require a central process with root privileges. This enhances system security. - Compatibility:
Podman commands are compatible with Docker CLI, meaning most commands are the same as Docker, which reduces the learning curve for users familiar with Docker. - Pod:
Podman introduces the concept of pods, similar to Kubernetes, allowing multiple containers to share the same network namespace.
Installation
# Ubuntu
sudo apt update -y
sudo apt install -y podman
# CentOS
sudo yum install -y podman
# Fedora
sudo dnf install -y podman
How to Use
Creating a Container
podman run -d --name my-nginx -p 8080:80 nginx
-d
stands for detached mode, meaning the container runs in the background.--name
lets you assign a human-readable name to the container, making it easier to identify different services.-p
maps the container's port to the host's port. 8080 is the host's port, and 80 is the port inside the container.
After running the container, you can check its status with:
podman ps
This command will show the current status of the container.
Entering the Container
podman exec -it my-nginx /bin/bash
Stopping and Deleting the Container
If you're using the container in interactive mode, you can type exit
to leave the container directly.
If you're outside the container, use the following commands:
Stopping the Container
podman stop my-nginx
Deleting the Container
To remove a container:
podman rm my-nginx
Viewing Podman Logs and Version Info
podman -v
podman logs my-nginx
The above commands cover the basic usage of Podman. In practice, Podman has many advanced features and customizable options. It is recommended to frequently refer to the official documentation for more specific needs.