[root@pp ~]# yum -y install podman
[root@pp ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@pp ~]#
[root@pp ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@pp ~]#
[root@pp ~]# cat /etc/containers/registries.conf
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "frz7i079.mirror.aliyuncs.com"
[root@pp ~]# podman pull docker.io/nginx
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob 186b1aaa4aa6 done
Copying blob b4df32aa5a72 done
Copying blob a0bcbecc962e done
Copying blob 589b7251471a done
Copying blob a9edb18cadd1 done
Copying blob a2abf6c4d29d done
Copying config 605c77e624 done
Writing manifest to image destination
Storing signatures
605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
[root@pp ~]# podman pull mysql
Resolving "mysql" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/mysql:latest...
Getting image source signatures
Copying blob 93619dbc5b36 done
Copying blob 37d5d7efb64e done
Copying blob 99da31dd6142 done
Copying blob ac563158d721 done
Copying blob 72a69066d2fe done
Copying blob 626033c43d70 done
Copying blob 688ba7d5c01a done
Copying blob d2ba16033dad done
Copying blob 4d7cfa90e6ea done
Copying blob 00e060b6d11d done
Copying blob 1c04857f594f done
Copying blob e0431212d27d done
Copying config 3218b38490 done
Writing manifest to image destination
Storing signatures
3218b38490cec8d31976a40b92e09d61377359eab878db49f025e5d464367f3b
[root@pp ~]#
[root@pp ~]# podman pull hub.c.163.com/library/centos
Trying to pull hub.c.163.com/library/centos:latest...
Getting image source signatures
Copying blob a3ed95caeb02 done
Copying blob a3ed95caeb02 done
Copying blob 2409c3878ba1 done
Writing manifest to image destination
Storing signatures
328edcd84f1bbf868bc88e4ae37afe421ef19be71890f59b4b2d8ba48414b84d
1 服务器IP: 端口 /分类 /镜像名 :tag
[root@pp ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/nginx latest 605c77e624dd 23 months ago 146 MB
docker.io/library/mysql latest 3218b38490ce 24 months ago 521 MB
hub.c.163.com/library/centos latest 328edcd84f1b 6 years ago 200 MB
[root@pp ~]#
1 podman tag 旧的镜像名 新的镜像名
[root@pp ~]# podman tag docker.io/library/mysql 192.168.248.45/rhce/mysql:v2
[root@pp ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/nginx latest 605c77e624dd 23 months ago 146 MB
docker.io/library/mysql latest 3218b38490ce 24 months ago 521 MB
192.168.248.45/rhce/mysql v2 3218b38490ce 24 months ago 521 MB
hub.c.163.com/library/centos latest 328edcd84f1b 6 years ago 200 MB
[root@pp ~]#
[root@pp ~]# podman rmi 192.168.248.45/rhce/mysql:v2
Untagged: 192.168.248.45/rhce/mysql:v2
[root@pp ~]
1 podman history镜像名
1 podman save 镜像名 > file.tar
[root@pp ~]# podman save docker.io/library/nginx > nginx.tar
[root@pp ~]#
删除 Nginx这个镜像,命令如下
[root@pp ~]# podman rmi docker.io/library/nginx
Untagged: docker.io/library/nginx:latest
Deleted: 605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
[root@pp ~]#
[root@pp ~]# podman load -i nginx.tar
Getting image source signatures
Copying blob d874fd2bc83b done
Copying blob e379e8aedd4d done
Copying blob 2edcec3590a4 done
Copying blob f1db227348d0 done
Copying blob b8d6e692a25e done
Copying blob 32ce5f6a5106 done
Copying config 605c77e624 done
Writing manifest to image destination
Storing signatures
Loaded image(s): docker.io/library/nginx:latest
[root@pp ~]# podman run hub.c.163.com/library/centos
[root@pp ~]# podman ps
\CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@pp ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5aa772f744c3 hub.c.163.com/library/centos:latest /bin/bash 14 seconds ago Exited (0) 14 seconds ago sleepy_kare
[root@pp ~]#
1 podman rm 容器ID/容器名
1 podman rm ‐f 容器ID/容器名
[root@pp ~]# podman rm 5aa772f744c3
5aa772f744c31875f10e83d1f5ffab7f69e4064ac5102596d4a88d1bdbbe3895
[root@pp ~]#
[root@pp ~]# podman run -it hub.c.163.com/library/centos
[root@fe4465083ddb /]# exit
exit
[root@pp ~]#
[root@pp ~]# podman ps ‐q #‐q选项可以只显示容器ID,不会显示太多信息
[root@pp ~]# podman ps -a -q
fe4465083ddb
[root@pp ~]#
[root@pp ~]# podman run -it --name=c1 --rm hub.c.163.com/library/centos
[root@10386f6b4e99 /]# exit
exit
[root@pp ~]#
[root@pp ~]# podman run -it --name=c1 --rm hub.c.163.com/library/centos sh
sh-4.2# exit
exit
[root@pp ~]#
[root@pp ~]# podman run -it --name=c1 --rm -e aa=123 -e bb=456 hub.c.163.com/library/centos
[root@8490fc4960c7 /]# echo $aa
123
[root@8490fc4960c7 /]# echo $bb
456
[root@8490fc4960c7 /]# exit
exit
[root@pp ~]#
[root@pp ~]# podman run -d --name=web --restart=always -p 80 docker.io/library/nginx
90813bcc5819e67e527d8abb715f083f2aa488a7aca853d288e29c985295c671
[root@pp ~]#
[root@pp ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
90813bcc5819 docker.io/library/nginx:latest nginx -g daemon o... 37 seconds ago Up 37 seconds ago 0.0.0.0:46327->80/tcp web
[root@pp ~]#
[root@pp ~]# podman rm -f web
90813bcc5819e67e527d8abb715f083f2aa488a7aca853d288e29c985295c671
1 podman exec 容器名 命令
1 podman cp /path/file 容器:/path2 把物理机中的/path/f1e拷贝到容器的/path2中
2 podman cp 容器:/path2/file /path/ 把容器中的/path2/l1e拷贝到物理机的/path2中
1 podman logs 容器名
1 podman logs ‐f 容器名
1 ‐v /dirl 把物理机的一个随机目录映射到容器的/dir1目录中
2 ‐v /dir2:/dirl:Z 把物理机的指定目录/dir2映射到容器的/dir1目录中
[root@pp ~]# podman run -dit --name=c1 --restart=always -v /data/ hub.c.163.com/library/centos
47a66e083be7982719257a535f580b955c989c7531ee4d5ef19c138821959d84
[root@pp ~]#
[root@pp ~]# podman inspect c1 | grep -A5 Mounts
"Mounts": [
{
"Type": "volume",
"Name": "cff4773d81248cef9997322c9de263f1ec680966735345305216b30642b690a7",
"Source": "/var/lib/containers/storage/volumes/cff4773d81248cef9997322c9de263f1ec680966735345305216b30642b690a7/_data",
"Destination": "/data",
[root@pp ~]#
[root@pp ~]# podman exec c1 ls /data/
[root@pp ~]# ls /var/lib/containers/storage/volumes/cff4773d81248cef9997322c9de263f1ec680966735345305216b30642b690a7/_data/
[root@pp ~]#
[root@pp ~]# podman cp /etc/hosts c1:/data/
[root@pp ~]# podman exec c1 ls /data/
hosts
[root@pp ~]# ls /var/lib/containers/storage/volumes/cff4773d81248cef9997322c9de263f1ec680966735345305216b30642b690a7/_data/
hosts
[root@pp ~]#
[root@pp ~]# mkdir /xx
[root@pp ~]# podman run -dit --name=c1 --restart=always -v /xx:/data/:z hub.c.163.com/library/centos7ecb9da861817aded61a29cf6aa2ab9a9d11005a213bf204335ac38416cc2ceb
[root@pp ~]#
[root@pp ~]# ls -dZ /xx
system_u:object_r:container_file_t:s0 /xx
[root@pp ~]#
[root@pp ~]# podman inspect c1 | grep -A5 Mounts
"Mounts": [
{
"Type": "bind",
"Source": "/xx",
"Destination": "/data",
"Driver": "",
[root@pp ~]#
[root@pp ~]# podman exec c1 ls /data/
[root@pp ~]# ls /xx/
[root@pp ~]# podman cp /etc/hosts c1:/data/
[root@pp ~]# podman exec c1 ls /data/
hosts
[root@pp ~]# ls /xx/
hosts
[root@pp ~]#
[root@pp ~]# podman rm -f c1
7ecb9da861817aded61a29cf6aa2ab9a9d11005a213bf204335ac38416cc2ceb
[root@pp ~]#
[iu@pp ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
[iu@pp ~]$
[iu@pp ~]$ podman pull docker.io/library/nginx
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob 186b1aaa4aa6 done
Copying blob a0bcbecc962e done
Copying blob 589b7251471a done
Copying blob b4df32aa5a72 done
Copying blob a2abf6c4d29d done
Copying blob a9edb18cadd1 done
Copying config 605c77e624 done
Writing manifest to image destination
Storing signatures
605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
[root@pp ~]# mkdir /yy
[root@pp ~]# chown iu.iu /yy/
[root@pp ~]#
[iu@pp ~]$ podman run -dit --name=web --restart=always -v /yy:/data/:Z docker.io/library/nginx
78aab24e798696415f31617adb43edfb6a06214bafb0c4cccbfefe90c1eb06ff
[iu@pp ~]$
[iu@pp ~]$ loginctl enable-linger iu
[iu@pp ~]$
[iu@pp ~]$ mkdir -p ~/.config/systemd/user ; cd ~/.config/systemd/user
[iu@pp user]$ ls
[iu@pp user]$
[iu@pp user]$ podman generate systemd --name web --files --new
/home/iu/.config/systemd/user/container-web.service
[iu@pp user]$
1 podman generate systemd ‐n web ‐f
[iu@pp user]$ systemctl --user daemon-reload
[iu@pp user]$
[iu@pp user]$ systemctl --user enable container-web.service
Created symlink /home/iu/.config/systemd/user/multi-user.target.wants/container-web.service → /home/iu/.config/systemd/user/container-web.service.
Unit /home/iu/.config/systemd/user/container-web.service is added as a dependency to a non-existent unit multi-user.target.
Created symlink /home/iu/.config/systemd/user/default.target.wants/container-web.service → /home/iu/.config/systemd/user/container-web.service.
[iu@pp user]$ ls
container-web.service default.target.wants multi-user.target.wants
[iu@pp user]$
[iu@pp ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78aab24e7986 docker.io/library/nginx:latest nginx -g daemon o... 15 minutes ago Up 15 minutes ago web
[iu@pp ~]$