Podman Systemd

Podman Systemd

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.

  • Used RHEL9 on VMware for demo.


  1. Run a container using the following command

podman run --name test -d docker.io/httpd        
No alt text provided for this image

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.

No alt text provided for this image

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        
No alt text provided for this image

4. Start the service

systemctl --user start service_name        
No alt text provided for this image
When we started the service the container is automatically deployed.

5. Stop the service.

systemctl --user stop service_name        
No alt text provided for this image
When the service is stopped the container also gets deleted.

6. Enable the service

systemctl --user enable service_name        
No alt text provided for this image

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
        
No alt text provided for this image

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.



要查看或添加评论,请登录

Dinesh Jagdish Verma的更多文章

  • Podman Checkpoint

    Podman Checkpoint

    What is Podman? Podman is a daemon-less container engine for developing, managing, and running OCI Containers on your…

    2 条评论

社区洞察

其他会员也浏览了