[root@localhost ~]# podman run -itd --rm --name test1 docker.io/library/busybox
[root@localhost ~]# podman run -itd --rm --name test2 docker.io/library/busybox
[root@localhost ~]# podman run -itd --rm --name test3 docker.io/library/busybox
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55c8eb032e0e docker.io/library/busybox:latest sh 27 seconds ago Up 27 seconds ago test1
d05f4d4014e8 docker.io/library/busybox:latest sh 12 seconds ago Up 13 seconds ago test2
d37c16cd8249 docker.io/library/busybox:latest sh 7 seconds ago Up 7 seconds ago test3
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# vim podman-container1.service
###podman-container1.service###
[Unit]
Description=Podman container1[Service]
Type=simple
ExecStart=/usr/bin/podman start -a test1
ExecStop=/usr/bin/podman stop -t 10 test1[Install]
WantedBy=multi-user.target[root@localhost system]# vim podman-container2.service
###podman-container2.service###
[Unit]
Description=Podman container2
After=network.target
After=network-online.target
After=podman-container1.service[Service]
Type=simple
ExecStart=/usr/bin/podman start -a test2
ExecStop=/usr/bin/podman stop -t 20 test2[Install]
WantedBy=multi-user.target[root@localhost system]# vim podman-container3.service
###podman-container3.service###
[Unit]
Description=Podman container3
After=network.target
After=network-online.target
After=podman-container2.service[Service]
Type=simple
ExecStart=/usr/bin/podman start -a test3
ExecStop=/usr/bin/podman stop -t 22 test3[Install]
WantedBy=multi-user.target
[root@localhost system]# systemctl enable podman-container1.service
Created symlink /etc/systemd/system/multi-user.target.wants/podman-container1.service → /usr/lib/systemd/system/podman-container1.service.
[root@localhost system]#
[root@localhost system]# systemctl enable podman-container2.service
Created symlink /etc/systemd/system/multi-user.target.wants/podman-container2.service → /usr/lib/systemd/system/podman-container2.service.
[root@localhost system]#
[root@localhost system]#
[root@localhost system]# systemctl enable podman-container3.service
Created symlink /etc/systemd/system/multi-user.target.wants/podman-container3.service → /usr/lib/systemd/system/podman-container3.service.
[root@localhost system]# reboot
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55c8eb032e0e docker.io/library/busybox:latest sh 4 minutes ago Up 25 seconds ago test1
d05f4d4014e8 docker.io/library/busybox:latest sh 4 minutes ago Up 25 seconds ago test2
d37c16cd8249 docker.io/library/busybox:latest sh 4 minutes ago Up 25 seconds ago test3
本文发布于:2024-02-02 10:24:20,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170684066143176.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |