Podman使用了/etc/containers/registries.conf和/etc/containers/storage.conf文件定义客户端环境配置。其中registries.conf定义了podman能够访问到的container registry服务器的信息,而storage.conf定义了podman保存在本地的容器镜像和其运行容器的文件目录。我们可以通过执行“podman info”查看这些配置是否生效。
$ podman info
host:
BuildahVersion: 1.9.0
Conmon:
package: podman-1.4.4-4.el7.x86_64
path: /usr/libexec/podman/conmon
version: 'conmon version 0.3.0, commit: unknown'
Distribution:
distribution: '"rhel"'
version: "7.7"
MemFree: 1084551168
MemTotal: 2096144384
OCIRuntime:
package: runc-1.0.0-65.rc8.el7.x86_64
path: /usr/bin/runc
version: 'runc version spec: 1.0.1-dev'
SwapFree: 2145644544
SwapTotal: 2147479552
arch: amd64
cpus: 1
hostname: registry
kernel: 3.10.0-1062.el7.x86_64
os: linux
rootless: false
uptime: 19h 40m 40.17s (Approximately 0.79 days)
registries:
blocked: null
insecure:
- registry.domain.com
search:
- docker.io
- registry.fedoraproject.org
- quay.io
- registry.access.redhat.com
- registry.centos.org
- registry.domain.com
store:
ConfigFile: /etc/containers/storage.conf
ContainerStore:
number: 2
GraphDriverName: overlay
GraphOptions: null
GraphRoot: /var/lib/containers/storage
GraphStatus:
Backing Filesystem: xfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
ImageStore:
number: 2
RunRoot: /var/run/containers/storage
VolumePath: /var/lib/containers/storage/volumes
系统全局的配置文件位于/etc/containers/registries.conf和/etc/containers/storage.conf,用户也可以使用“~/.config/containers/registries.conf”、“~/.config/containers/storage.conf”覆盖系统全局的配置。
在registries.conf文件中“[registries.search]”是podman搜索镜像的目标registry,而“[registries.insecure]”定义了可以不通过TLS访问的registry。
[registries.search]
registries = ['registry.access.redhat.com', 'registry.redhat.io', 'docker.io']
[registries.insecure]
registries = []
[registries.block]
registries = []
在storage.conf文件中,“graphroot”参数是用来定义存放Image和容器可写内容的目录(其下面对应相关的子目录);而“runroot”参数是用来定义存放容器临时可写内容的目录;“VolumePath”参数指定了“podman volume create”命令创建的目录位置。
$ podman login -u user1 -p password1 ${REGISTRY_DOMAIN}:5000
$ podman search docker.io/busybox --limit 3
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/library/busybox Busybox base image. 1931 [OK]
docker.io docker.io/radial/busyboxplus Full-chain, Internet enabled, busybox made f... 31 [OK]
docker.io docker.io/yauritux/busybox-curl Busybox with CURL 8
$ podman search ${REGISTRY_DOMAIN}:5000/busybox --limit 3
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
domain.com:5000 registry.domain.com:5000/busybox 0
$ podman pull busybox
Trying to pull docker.io/library/busybox...Getting image source signatures
Copying blob 91f30d776fb2 done
Copying config c7c37e472d done
Writing manifest to image destination
Storing signatures
c7c37e472d31c1685b48f7004fd6a64361c95965587a951692c5f298c6685998
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest c7c37e472d31 2 days ago 1.44 MB
$ PODMAN_DATA_DIR=/var/lib/containers/storage
$ ll ${PODMAN_DATA_DIR}/overlay-images
total 8
drwx------. 2 root root 244 Jul 2 13:55 c7c37e472d31c1685b48f7004fd6a64361c95965587a951692c5f298c6685998
-rw-------. 1 root root 1134 Jul 2 13:55 images.json
-rw-------. 1 root root 64 Ju
l 2 13:55 images.lock
当podman访问Registry的时候进行build、commit、pull或push操作的时候,如果所访问的Registry在“[registries.insecure]”中,那么podman缺省用“–tls-verify=false”发起请求。如果访问其它Registry(没有在registries.conf中定义或在registries.conf中定义为“[registries.search]”),podman缺省用“–tls-verify=true”发起请求。如果需要不使用上述缺省访问,可以在命令中会用“–tls-verify”。
$ podman image tree busybox
Image ID: c7c37e472d31
Tags: [docker.io/library/busybox:latest]
Size: 1.444MB
Image Layers
└── ID: 50761fe126b6 Size: 1.442MB Top Layer of: [docker.io/library/busybox:latest]
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest c7c37e472d31 4 days ago 1.44 MB
$ podman save --quiet -o busybox.tar docker.io/library/busybox:latest
Getting image source signatures
Copying blob 50761fe126b6 done
Copying config c7c37e472d done
Writing manifest to image destination
Storing signatures
$ ll busybox.tar
-rw-r--r--. 1 root root 1451008 Jul 3 16:08 busybox.tar
$ podman rmi docker.io/library/busybox:latest
c7c37e472d31c1685b48f7004fd6a64361c95965587a951692c5f298c6685998
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
$ podman load --quiet -i busybox.tar
Loaded image(s): docker.io/library/busybox:latest
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest c7c37e472d31 4 days ago 1.44 MB
$ podman run --name busybox-local -it ${REGISTRY_DOMAIN}:5000/busybox
/ # mkdir mydir1
/ # echo hello > mydir1/hello.txt
/ # hostname
84625108be74
$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84625108be74 registry.domain.com:5000/busybox:latest sh 1 minutes ago Up 1 minutes ago busybox-local
$ ps -ef | grep busybox
root 5340 1 0 13:52 ? 00:00:00 /usr/libexec/podman/conmon -s -c 84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686 -u 84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686 -n busybox-local -r /usr/bin/runc -b /var/lib/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata -p /var/run/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata/pidfile --exit-dir /var/run/libpod/exits --exit-command /usr/bin/podman --exit-command-arg --root --exit-command-arg /var/lib/containers/storage --exit-command-arg --runroot --exit-command-arg /var/run/containers/storage --exit-command-arg --log-level --exit-command-arg error --exit-command-arg --cgroup-manager --exit-command-arg systemd --exit-command-arg --tmpdir --exit-command-arg /var/run/libpod --exit-command-arg --runtime --exit-command-arg runc --exit-command-arg --storage-driver --exit-command-arg overlay --exit-command-arg container --exit-command-arg cleanup --exit-command-arg 84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686 --socket-dir-path /var/run/libpod/socket -t -l k8s-file:/var/lib/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata/ctr.log --log-level error
$ more /var/run/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata/pidfile
5340
$ more /var/run/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata/hostname
84625108be74
$ more /var/run/containers/storage/overlay-containers/84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686/userdata/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.6 registry.domain.com
10.88.0.21 84625108be74
$ podman mount
84625108be74 /var/lib/containers/storage/overlay/8a1697a77a6f7acc87a6ce5042c7b890b30260bf8d64c31f01105af5adf3cf12/merged
$ find / -name hello.txt
/var/lib/containers/storage/overlay/8a1697a77a6f7acc87a6ce5042c7b890b30260bf8d64c31f01105af5adf3cf12/diff/mydir1/hello.txt
/var/lib/containers/storage/overlay/8a1697a77a6f7acc87a6ce5042c7b890b30260bf8d64c31f01105af5adf3cf12/merged/mydir1/hello.txt
/ # exit
$ find / -name hello.txt
/var/lib/containers/storage/overlay/8a1697a77a6f7acc87a6ce5042c7b890b30260bf8d64c31f01105af5adf3cf12/diff/mydir1/hello.txt
$ podman diff busybox-local
C /etc
A /mydir1
A /mydir1/hello.txt
C /root
A /root/.ash_history
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84625108be74 registry.domain.com:5000/busybox:latest sh 48 seconds ago Exited (0) 30 seconds ago busybox-local
$ podman logs busybox-local
/ # mkdir mydir1
/ # echo hello > ./mydir1/hello.txt
/ # exit
$ podman stats --all
ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS
e8193ad15aee busybox-local -- 53.25kB / 2.096GB 0.00% 698B / 656B -- / -- 1
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84625108be74 registry.domain.com:5000/busybox:latest sh 48 seconds ago Exited (0) 30 seconds ago busybox-local
$ podman run --name busybox-local -it ${REGISTRY_DOMAIN}:5000/busybox
Error: error creating container storage: the container name "busybox-local" is already in use by "84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686". You have to remove that container to be able to reuse that name.: that name is already in use
$ podman start busybox-local
84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686
$ podman attach busybox-local
/ # exit
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84625108be74 registry.domain.com:5000/busybox:latest sh 44 minutes ago Exited (0) 7 minutes ago busybox-local
$ podman rm busybox-local
84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686
$ podman container prune
84625108be74a36b64e24edec59483c5340d0f768d7355a3c64ec7660dd80686
$ find / -name hello.txt
$ podman system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 1 0 1.44MB 1.44MB (100%)
Containers 0 0 0B 0B (0%)
Local Volumes 1 0 0B 0B (0%)
$ podman system prune --all --volumes
https://fossies.org/linux/libpod/troubleshooting.md