[root@cxr ~]# podman pull busybox
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
Getting image source signatures
Copying blob 5cc84ad355aa done
Copying config beae173cca done
Writing manifest to image destination
Storing signatures
beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a
[root@cxr ~]# podman run --name test -dit docker.io/library/busybox
WARN[0000] Ignoring global metacopy option, not supported with booted kernel
5a27696f3351fa9a80b81c1d7c90aa781eddbc47774340baa241572f6070ae87
[root@cxr ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
388bf8e619a0 docker.io/library/nginx:latest nginx -g daemon o... 53 minutes ago Up 53 minutes ago 0.0.0.0:8080->80/tcp web
5a27696f3351 docker.io/library/busybox:latest sh 28 seconds ago Up 28 seconds ago test
[root@cxr ~]# podman generate systemd --files --name test
/root/container-test.service
[root@cxr ~]# podman generate systemd --files --name test --new
/root/container-test.service
[root@cxr ~]# mv container-test.service /usr/lib/systemd/system/
[root@cxr ~]# systemctl daemon-reload
[root@cxr ~]# setenforce 0
[root@cxr ~]# vim /etc/selinux/config
SELINUX=disabled
[root@cxr ~]# systemctl enable --now container-test.service
Created symlink /etc/systemd/system/default.target.wants/container-test.service → /usr/lib/systemd/system/container-test.service.
[root@cxr ~]# reboot
连接断开
连接成功
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Tue May 10 02:52:36 2022 from 192.168.106.1
[root@cxr ~]# podman ps //可以看到已经开机自启了
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f56bd4002398 docker.io/library/busybox:latest sh 9 seconds ago Up 7 seconds ago test
普通用户
[root@cxr ~]# useradd jerry
[root@cxr ~]# su - jerry
[jerry@cxr ~]$ podman pull busybox
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
Getting image source signatures
Copying blob 3cb635b06aa2 done
Copying config ffe9d497c3 done
Writing manifest to image destination
Storing signatures
ffe9d497c32414b1c5cdad8178a85602ee72453082da2463f1dede592ac7d5af
[jerry@cxr ~]$ podman run --name test -dit docker.io/library/busybox
b1cbea168be3ced718bdae93c4c6cdc7405d0f0f9380c856e3d76d9496901c60
[jerry@cxr~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b1cbea168be3 docker.io/library/busybox:latest sh 5 seconds ago Up 5 seconds ago test
#创建service文件
[jerry@cxr ~]$ podman generate systemd --files --name test --new
/home/jerry/container-test.service
[jerry@cxr ~]$ ls
container-test.service
[jerry@cxr ~]$ mkdir -p ~/.config/systemd/user
[jerry@cxr ~]$ mv container-test.service ~/.config/systemd/user
[jerry@cxrt ~]$ systemctl --user status container-test.service
● container-test.service - Podman container-test.service
Loaded: loaded (/home/jerry/.config/systemd/user/container-test.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-5-23 22:31:21 CST; 10s ago
Docs: man:podman-generate-systemd(1)
Process: 107992 ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=/run/user/1002/container-test.service.ctr-id (code=exited, status=125)
Process: 108050 ExecStartPre=/bin/rm -f /run/user/1002/container-test.service.ctr-id (code=exited, status=0/SUCCESS)
Main PID: 108141 (conmon)
CGroup: /user.slice/user-1002.slice/user@1002.service/container-test.service
├─108134 /usr/bin/fuse-overlayfs -o ,lowerdir=/home/jerry/.local/share/containers/storage/overlay/l/7EWWT2U3CWUJFPIPVXBNGBWGFI,upperdir=/home/jerry/.local/share/>
├─108138 /usr/bin/slirp4netns --disable-host-loopback --mtu=65520 --enable-sandbox --enable-seccomp -c -e 3 -r 4 --netns-type=path /run/user/1002/netns/cni-370af>
├─108141 /usr/bin/conmon --api-version 1 -c 4ca23486d3ab0cb9a230265df8b9d5a666bfdfbd42785ac90b92bf965a4b37cc -u 4ca23486d3ab0cb9a230265df8b9d5a666bfdfbd42785ac90>
└─108144 sh
[jerry@cxr ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ca23486d3ab docker.io/library/busybox:latest sh 19 seconds ago Up 19 seconds ago