Home  >  Article  >  Computer Tutorials  >  How to install Podman on Ubuntu 24.04

How to install Podman on Ubuntu 24.04

WBOY
WBOYforward
2024-03-22 11:26:43939browse

如何在Ubuntu 24.04上安装Podman

If you have used Docker, you must understand daemons, containers, and their functions. A daemon is a service that runs in the background when a container is already in use in any system. Podman is a free management tool for managing and creating containers without relying on any daemon such as Docker. Therefore, it has advantages in managing containers without the need for long-term backend services. Additionally, Podman does not require root-level permissions to be used. This guide discusses in detail how to install Podman on Ubuntu 24.

Update system

We first need to update the system and open the Terminal shell of Ubuntu 24. During both installation and upgrade processes, we need to use the command line. A simple way is to use Ubuntu's "apt" utility and prepend the "update" command with sudo permissions. This command updates system utilities and repositories to ensure that potential conflicts do not occur when new software and applications are installed. You can also perform system upgrades and updates if needed.

sudo apt update

Install Podman

After upgrading to Ubuntu 24 system, we can continue to install Podman. Installation using the "apt" tool is very convenient and is easy to find in the installation instructions. In order to force the installation of Podman, we can use the "-y" flag. So just run the following command to start the installation:

sudo apt install—y podman

Installing the Podman tool may take longer than a regular installation, so you will need to wait patiently until the installation is complete.

After waiting for some time, Podman will be installed and its symbolic links will be created, as shown in the output:

Verify installation

In order to confirm that the Podman tool is successfully installed and configured in the Ubuntu 24 system, we can use a simple version command to find the installed version of Podman.

Sudabodman-Version

To get information about the Podman tool installed in your terminal, you can also use the "info" command with sudo privileges as follows:

Sudo Podman info

Run containers through Podman

We can say that a container is a service that uses different images for processing. You can create containers or use ones already built in. So we have to pull the container out and run it on our end. To do this, we use the "Run" directive, the "-it" flag and the container name, i.e., hello world it will start pulling the container from its primary source and run it on our end.

Sudo Podman Run—it Hello—World

After executing this "Run" instruction, you will get the following output. You can see that this container is pulled from Docker's main source:

Now we can find all containers currently running on Ubuntu24. To do this, we use the Podman command with the "ps" option shown below. The output of this command shows that there are currently no working containers. We can use the "-a" flag in the same directive while finding all pulled containers. You can see that the output with the "-a" option shows information for one container.

  • Several Boardman PS
  • Sudo Boardman PS—A

Remove container

Just like adding a new container to the system, you can also use the Podman tool to remove any added container from the Ubuntu 24 system. You must use the "rm" option in the Podman command along with sudo permissions. Make sure to mention the container ID after the "rm" option in the same query. Containers with specific IDs will be permanently removed.

Sudo Podman rm 9bd8d19ef028

Using images via Podman

An image in a Podman environment is known as the set of instructions required to run a container service or application. Therefore, to run Podman containers we need a specific image. To list all available images on Ubuntu 24, you need to use the same Podman command, using the "images" keyword. It will display all the images available in the system, i.e. d2c94e258dcb.

Sudo Boardman Pictures

To get a new image for your Podman environment, you can run the "Pull" command with the name of the new image, i.e. "Debain", as shown in the attached image.

Sudo podman pull Debian

After using the image description again, you can see that the new image has been downloaded successfully.

Sudo Boardman Pictures

Create a container in Podman

Now that the image has been downloaded, we must run it to create a container with a user-defined name. To do this, Podman's "run" command will be executed with the "-dit" and "-name" flags, followed by the name of the container, i.e. "Debian-container", and the name of the image you just downloaded, i.e. "Debian" . You can also see it working in Podman after creating a container from a "Debian" image.

  • Sudo Podman run—dit—name debian—container debian
  • Several Boardman PS

To connect to a newly running container named "debian-container", you need to use Podman's "attach" command. You can work in this container.

Sudo Podman Attach Debian—Container

To get the version of a container, run the following command in this container:

Cat/etc/os—release

Now, to exit a container and prevent it from running, you must use the "exit" command, followed by the Podman "Stop" command, using the name of the specific container.

  • exit
  • sudo podman stop debian container

To start, stop and delete the Podman container, you can use the following commands in sequence:

  • Sudo podman starts Debian-container
  • sudo podman stop debian container
  • Sudo Podman rm debian—container

You can remove the Podman image using the "RMI" option in the same "Remove" command.

sudo podman rmi debian

Boardman

Now it’s time to uninstall the Podman tool from your Ubuntu system using the “Remove” command. Using the "apt" utility is a must since we installed it with "apt".

Sudo apt remove Podman

in conclusion

This guide describes how to use containers and images through the Podman tool. We elaborate on the main differences between Podman and Docker services. After that, we detailed the easiest way to install Podman in Ubuntu 24 and pulled some containers and images. After that, we learned how to use containers using images and the steps to uninstall the Podman service.

The above is the detailed content of How to install Podman on Ubuntu 24.04. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete