Podman Systemd
Dinesh Jagdish Verma
"DevOps Engineer with a passion for automation and cloud infrastructure" | RHCSA Certified | CCA Certified | Docker | Podman | AWS | Linux | CENTOS | UBUNTU | Fedora | OPENSUSE | Kubernetes |
Podman is a fully featured container engine that is a simple daemonless tool.?Podman provides a Docker-CLI comparable command line that eases the transition from other container engines and allows the management of pods, containers and images.
Podman uses systemd — a system and service manager for Linux operating systems — to make updates and keep containers running in the background.?By integrating systemd and Podman, you can generate control units for your containers and run them with systemd automatically enabled.
You can use?podman to generate systemd?to create a systemd unit file that can be used to control a container or pod. By default, the command will print the content of the unit files to stdout.?Generating unit files for a pod requires the pod to be created with an infra container.
Systemd is the service manager tool in RHEL OS. It manages the services on the host machine. To convert a container as a service the following example is done.
How to create a podman systemd service for a normal user.
podman run --name test -d docker.io/httpd
2. Create a unit file.
podman generate systemd --new --name container_name
podman generate systemd?will create a systemd unit file that can be used to control a container or pod. By default, the command will print the content of the unit files to stdout.
Then we have to save the output of the unit file to the directory called $HOME/.config/systemd/user
3. Check the service state
systemctl --user status service_name
领英推荐
4. Start the service
systemctl --user start service_name
5. Stop the service.
systemctl --user stop service_name
6. Enable the service
systemctl --user enable service_name
When we enable any service it creates a soft link in the directory $HOME/.config/systemd/user/default.target.wants
Through which the systemd will run the service whenever the host is rebooted.
7. Disable the service
systemctl --user disable service_name
When the service is disabled it removes the soft from the directory called $HOME/.config/systemd/user/default.target.wants
Through this, the systemd will not start this service on reboot.