Podman is a command-line utility for running and managing containers on Linux systems. It is an alternative to Docker that provides many of the same features and functionality, but without requiring a daemon to be running in the background. In this tutorial, we will show you how to install and use Podman to run containers on Rocky Linux 8.
Prerequisites
Before getting started, make sure you have a clean installation of Rocky Linux 8 and that you are logged in as a user with sudo privileges. You will also need to have the dnf
package manager installed on your system.
To check if dnf
is installed, you can use the following command:
dnf --version
If dnf
is not installed, you can install it by running the following command:
sudo dnf install dnf
Once dnf
is installed, you are ready to proceed with installing Podman.
Step 1: Install Podman
To install Podman on Rocky Linux 8, we will use the dnf
package manager. To install Podman, run the following command:
sudo dnf install podman
This will download and install the Podman package and all of its dependencies. The installation process may take a few minutes to complete.
Once the installation is finished, you can verify that Podman is installed and working by running the following command:
podman --version
This will print the version of Podman that is installed on your system.
Step 2: Run a container
With Podman installed, you can start running containers on your Rocky Linux 8 system. To run a container, you can use the podman run
command, followed by the image name and any options or arguments.
For example, to run the hello-world
image, you can use the following command:
podman run hello-world
This will download the hello-world
image from the Docker registry, if it is not already present on your system, and run a container based on that image. The container will print a message and then exit.
To run a container in the background, you can use the -d
option:
podman run -d hello-world
This will run the hello-world
container in the background, and print the container ID.
To run a container with a specific name, you can use the --name
option:
podman run --name my-hello-world hello-world
This will run the hello-world
container with the name my-hello-world
.
Step 3: List containers
To view the containers that are currently running on your system, you can use the podman ps
command. This command will show a list of containers, including their ID, name, image, and status.
For example, to list the containers that are currently running on your system, you can use the podman ps
command:
podman ps
This will show a list of containers that are currently running, along with their ID, name, image, and status.
To show all containers, including those that are stopped, you can use the -a
option:
podman ps -a
This will show a list of all containers, including those that are stopped or exited.
Step 4: Stop and start containers
To stop a running container, you can use the podman stop
command, followed by the container ID or name. For example, to stop the hello-world
container, you can use the following command:
podman stop hello-world
This will stop the hello-world
container and terminate its processes.
To start a stopped container, you can use the podman start
command, followed by the container ID or name. For example, to start the hello-world
container, you can use the following command:
podman start hello-world
This will start the hello-world
container and resume its processes.
Step 5: Remove containers
To remove a container from your system, you can use the podman rm
command, followed by the container ID or name. For example, to remove the hello-world
container, you can use the following command:
podman rm hello-world
This will remove the hello-world
container and delete its data and configuration.
To remove all containers, including those that are stopped or exited, you can use the -a
option:
podman rm -a
This will remove all containers from your system.
Conclusion
In this tutorial, you learned how to install and use Podman to run containers on Rocky Linux 8. You learned how to run, stop, start, and remove containers, and how to list the containers that are currently running on your system. With Podman installed and configured, you can start running and managing containers on your Rocky Linux 8 system.