Original link: https://editor.leonh.space/2022/podman/
Summary of the previous situation: I mentioned in the self-built Drone CI article before that the Drone server there is run with Podman, and the article leaves a suspense at the end “how to make the Drone server / Drone runner become a service, and the machine will start by itself? “And this article is the answer given by Podman.
Podman
First of all, get to know Podman, it can be regarded as a replacement for Docker, but it is not just imitating cats, it has the following characteristics:
- Apache is open source licensed, developed by Red Hat, has a rich dad, and has not been released yet, and is still actively developing.
- It does not need root privileges to run, and it is not a daemon service. This design is a little safer than Docker (but it also takes some means to set it up as a service).
- And Docker instructions have nine images that can be converted in seconds.
- Different from Docker, Podman has the concept of pod, that is, a service cluster, which feels a little closer to the trendiest K8s.
- For those who are used to Docker Compose, there is also Podman Compose .
- There is also Podman Desktop similar to Docker Desktop, and don’t worry about its commercial licensing.
In addition to the last point listed above, according to Docker’s licensing terms, as long as Docker Desktop is commercial and the company scale exceeds a certain level, Docker Desktop must be paid, while Docker Engine is still free to use. The approximate differences between the two are as follows:
- Docker Engine: Docker daemon + Docker CLI
- Docker Desktop: Docker Engine + Docker GUI + Docker VM
To put it simply, Decker Desktop has a GUI. For non-Linux systems, it will also help you build a VM, which is really considerate, but as a developer, you will use Docker, how can you still be attracted by GUI, and how can you be trapped by VM Live, on the other hand, for non-developers, Docker GUI will not be used, so it is better to learn from CLI obediently, so it seems that Docker GUI is useless.
In short, I’m free boy ~ bring the topic back to Podman.
Podman installation
Podman’s own installation instructions are quite lengthy, but they can be done in one line:
$ sudo apt-get install podman
Yes, Ubuntu’s original APT library has Podman, the current version is 3.4, and Podman’s latest version is 4.0, which is slightly behind but does not affect use.
Podman use
Because it is Docker copycat, the instructions are almost the same, the difference is to use the full URL when grabbing the image, such as:
- In Docker, the image address is gitea /gitea:latest, and in Podman, the image address is docker.io/gitea/gitee:latest .
- In Docker, the image address is httpd, and in Podman , the image address is docker.io/library/httpd. If there is no organization, put ” library ” instead.
Take Ubuntu as an example, if you want to open a disposable container, use:
$ podman pull docker.io/library/ubuntu:22.04 $ podman run --interactive --tty --rm ubuntu:22.04 bash
For a more complete usage, take Gitea as an example:
Grab the Gitea image:
$ podman pull docker.io/gitea/gitea:latest
Create a Gitea data directory:
$ sudo mkdir -p /var/lib/gitea
start running:
$ podman run \ -d \ --name =gitea \ -p 14415:22 \ -p 14416:3000 \ -v /var/lib/gitea:/data \ gitea/gitea:latest
Make the container a service
As mentioned earlier, Podman itself will not be registered as a service, but sometimes it is necessary to run some containers as a service. Podman also thoughtfully imagined that it can quickly help us generate Linux systemd service configuration files.
Suppose there is a container called drone. To generate its systemd service configuration file, use the following command:
$ podman generate systemd --name drone --files
It will generate a container-drone.service file, move the file to ~/.config/systemd/user/:
$ sudo mv ~ /container-drone.service ~ /.config/systemd/user/
Let it start automatically:
$ systemctl --user daemon-reload $ systemctl --user enable container-drone.service
Let it start right away:
$ systemctl --user start container-drone.service
Confirm service status:
$ systemctl --user status container-drone.service
post job
The above services are running on non-root accounts, and linger needs to be additionally enabled. This feature is to enable the current account to automatically log in when it is turned on, and start the service.
$ sudo loginctl enable-linger
Last but not least, reboot to see if everything is working properly.
This article is reprinted from: https://editor.leonh.space/2022/podman/
This site is for inclusion only, and the copyright belongs to the original author.