# Introduction
Podman is a free, open-source and daemonless tool designed to make it easy to find, run, build, share and deploy applications using Open Containers Initiative (OCI) Containers and Container Images. It provides a command-line tool for managing containers and images, volumes mounted into those containers, and pods made from groups of containers. Podman uses libpod library to manage pods, containers, container images, and container volumes.
In this post, we will show you how to install and use Podman to deploy and manage containers on Debian 11.
# Requirements
- A server running Debian 11 operating system.
- A root password is set up on your server.
# Install Podman
By default, the Podman package is included in the Debian 11 default repository. You can install it using the following command:
apt-get install podman -y
Once the Podman is installed, you can verify the installed version of Podman with the following command:
podman --version
You will get the following output:
podman version 3.0.1
To gather more information about Podman, run the following command:
podman info
You will get the following output:
host:
arch: amd64
buildahVersion: 1.19.6
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: 'conmon: /usr/bin/conmon'
path: /usr/bin/conmon
version: 'conmon version 2.0.25, commit: unknown'
cpus: 2
distribution:
distribution: debian
version: "11"
eventLogger: journald
hostname: debian11
idMappings:
gidmap: null
uidmap: null
kernel: 5.10.0-8-amd64
linkmode: dynamic
# Configure Podman
Podman uses registries to push and pull images over the internet. So you will need to define it in the Podman registries file.
nano /etc/containers/registries.conf
Add the following lines at the end of the file:
[registries.search]
registries = ['docker.io', 'quay.io', 'registry.access.redhat.com']
[registries.insecure]
registries = []
[registries.block]
registries = []
Save and close the file when you are finished.
# Pulling an Image from the Registry
Before pulling any images, you will need to search the image for their availability across various registries. For example, search the Apache2 image using the following command:
podman search apache2
You should see all apache2 images in the following output:
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/firespring/apache2-php Based on Ubuntu 16.04. Contains php and a ba... 11 [OK]
docker.io docker.io/antage/apache2-php5 Docker image for running Apache 2.x with PHP... 24 [OK]
docker.io docker.io/oberonamsterdam/apache24-fpm Default Oberon apache setup using PHP-FPM, r... 2 [OK]
docker.io docker.io/teamrock/apache2 TeamRock's Apache2 8 [OK]
docker.io docker.io/ascdc/apache2-php56 apache2-php56 2 [OK]
docker.io docker.io/antage/apache2-php7 Docker image for running Apache 2.x with PHP... 1 [OK]
docker.io docker.io/kstaken/apache2 This a small Apache2 build that can be exten... 3
docker.io docker.io/ascdc/apache2-php7 apache2 + php7 5 [OK]
docker.io docker.io/jmferrer/apache2-reverse-proxy Dockerized apache2 reverse proxy service. 2
docker.io docker.io/marvambass/apache2-ssl-secure apache2 - (marvambass/apache2-ssl-secure) (+... 5 [OK]
docker.io docker.io/solution360/apache2-php7-ioncube Apache2.4 with PHP7 and ioncube. 2 [OK]
docker.io docker.io/caladreas/apache2-openidc-docker Naieve docker container configuration for Ap... 1 [OK]
docker.io docker.io/garelp/apache2-galette Galette installation with php7 and apache2 f... 1
docker.io docker.io/mhenry07/apache2-utils Alpine image with apache2-utils (htpasswd, e... 2
docker.io docker.io/enonicio/apache2 Base Docker image for apache2 1 [OK]
docker.io docker.io/navanieethks/apache2-nav apache2 test container 0
docker.io docker.io/enoniccloud/apache2-letsencrypt Apache2 container with letsencrypt integrate... 1 [OK]
Now, use any on the registry from the above output and pull it using the following command:
podman pull docker.io/enonicio/apache2
Once the Apache2 image has been downloaded, you will get the following output:
Trying to pull docker.io/enonicio/apache2:latest...
Getting image source signatures
Copying blob f5e83780ccda done
Copying blob 1eb2c989bc04 done
Copying blob 2dec31d7323c done
Copying blob 050aa9ae81a9 done
Copying blob 286f32949bdc done
Copying blob b402972d58df done
Copying blob 13c965b03bf5 done
Copying blob 63d6284a7719 done
Copying blob 323483328ff9 done
Copying blob 0a8e151da91a done
Copying blob 14bb6c07ac49 done
Copying blob 13466d328a5d done
Copying blob 99d1f30a09ca done
Copying blob 156c6aec6e4a done
Copying config 8087d2ab62 done
Writing manifest to image destination
Storing signatures
8087d2ab62bcb38ea6c7cfac7360206ef4bca3493eb0d71931c20319ab6a7378
You can now verify the downloaded image using the following command:
podman images
You should see the following output:
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/enonicio/apache2 latest 8087d2ab62bc 3 years ago 267 MB
# Run a COntainer from an Image
You can now create and run a container from the downloaded image using the following syntax:
podman run -d --name container-name image
For example, run the following command to create a container named web from an Apache image:
podman run -d --name web docker.io/enonicio/apache2
Once the container has been created, you can check it using the following command:
podman ps
You will get the running container in the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fbbf0b7ed29f docker.io/enonicio/apache2 /bin/sh -c apache... 7 seconds ago Up 7 seconds ago web
To check the container log, run the following command:
podman logs web
You should see the following output:
[Tue Oct 19 14:30:00.210131 2021] [core:notice] [pid 2:tid 139865785894784] AH00094: Command line: 'apache2 -D FOREGROUND'
# Start and Stop a Container
You can start and stop any container easily using the Podman.
For example, to stop the container named web use the following command:
podman stop web
To start the container named web, run the following command:
podman start web
If you want to list all running and stopped containers, run the following command:
podman ps -a
# Connect the Shell of a Container
Podman also allows you to create a container and access their shell from the command-line.
To do so, first pull the ubuntu image using the following command:
podman pull docker.io/takkatakka/lftp
You will get the following output:
Trying to pull docker.io/takkatakka/lftp:latest...
Getting image source signatures
Copying blob d967c497ce23 done
Copying blob 67de21feec18 done
Copying blob a9b30c108bda done
Copying blob d3938036b19c done
Copying blob 6267a2c9cabc done
Copying blob 817da545be2b done
Copying config e1f5e88d6a done
Writing manifest to image destination
Storing signatures
e1f5e88d6a190f73a8ca156f32ac9c890b768666291217e9f93805eaef8618b3
Now, create a container and connect it to their shell with the following command:
podman run --name ubuntu -it docker.io/takkatakka/lftp /bin/bash
Once the container has been started, you will get into the shell as shown below:
root@290e979f59b3:/#
You can now run any commands inside the Ubuntu container. For example, to check the Ubuntu version of running container using the following command:
root@290e979f59b3:/# cat /etc/lsb-release
You will get the following output:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
If you want to exit from the Container shell, run the following command:
root@290e979f59b3:/#
# Display Container Statistics
If you want to check the stats of the running container, run the following command:
podman stats
To display the intricate details about a container, run the following command:
podman inspect ubuntu
You will get the following output:
[
{
"Id": "290e979f59b36b2721fc08358499e52743b80d70fd0d8c4cba201dea3270d214",
"Created": "2021-10-19T14:33:44.899825285Z",
"Path": "/bin/bash",
"Args": [
"/bin/bash"
],
"State": {
"OciVersion": "1.0.2-dev",
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 0,
"Error": "",
"StartedAt": "2021-10-19T14:33:45.151655924Z",
"FinishedAt": "2021-10-19T14:34:28.069994897Z",
"Healthcheck": {
"Status": "",
"FailingStreak": 0,
# Remove the Container
If you want to remove a container, you will need to stop it first.
To stop the container named web, run the following command:
podman stop web
Next, remove a container using the following command:
podman rm web
Next, remove the container image using the following command:
podman rmi imageid
You can see the ImageId using the podman images command.
If you want to stop and remove the latest container, run the following command:
podman stop --latest
podman rm --latest
# Conclusion
Congratulations! You have successfully installed Podman on Debian 11. You can now easily create, run, maintain and secure containers using Podman. For more information, visit the Podman documentation.