安装
官网链接: podman.io/docs/instal…
本机为 window 11 的 Ubuntu wsl 系统:
# Ubuntu 20.10 and newer
sudo apt-get update
sudo apt-get -y install podman
配置文件
/etc/containers/registries.conf
conf 是配置文件,指定在完成不包含注册表或域部分的映像名称时应该参考哪个容器注册表。
/usr/share/containers/mounts.conf和/etc/containers/mounts.conf配置文件mounts.conf指定了在执行podman run或podman build命令时在容器中自动挂载的卷挂载目录,然后容器进程可以使用这个内容,卷挂载内容不会提交到最终映像中。
通常这些目录用于传递包软件访问远程包存储库所需的秘密或凭据。
例如,mounts.conf 文件中包含一行 " /usr/share/rhel/secrets:/run/secrets ", 即 /usr/share/rhel/secrets 目录的内容被挂载到容器中的 /run/secrets 上,这个挂载点允许在容器中使用来自主机的 Red Hat Enterprise Linux 订阅。
注意这不是卷挂载。卷的内容被复制到容器存储中,而不是直接从主机绑定挂载。
来自 Fedora containers-common 包的示例:
cat /usr/share/containers/mounts.conf
/usr/share/rhel/secrets:/run/secrets
/usr/share/containers/seccomp.json
seccomp.json 包含了在容器中允许使用的 seccomp 规则的白名单。这个文件通常由 containers-common 包提供。
/etc/containers/policy.json
使用国内镜像
- 首先备份源文件
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.bak
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
insecure = true
location = "docker.nju.edu.cn"
[[registry]]
insecure = true
location = "hub-mirror.c.163.com"
prefix是 pull 的时候指定的镜像前缀,location是获取镜像的地址,如果不指定prefix则默认和location一致。insecure=true表示允许通过HTTP协议来获取镜像,对于私有化部署/内网测试环境下无https证书的环境来说很有帮助。 测试
podman run hello-world
更多镜像:gist.github.com/y0ngb1n/7e8…
常见问题
- 出现
WARN[0000] The cgroupv2 manager is set to systemd but there is no systemd user session available #12983问题github issue: github.com/containers/…
安装 dbus-user-session 包然后重启 wsl 子系统后警告信息消失