12.3 Podman
Podman 旨在代替 Docker,同时与 Docker 的命令几乎完全相同,你甚至能设置别名来使用。
Podman 在 FreeBSD 上的实现是基于 Jail 的,你可以用命令 jls 查看当前的容器。
安装 Podman
我们安装 sysutils/podman-suite 这个元包,会帮我们安装 sysutils/buildah、sysutils/podman 和 sysutils/skopeo。
使用 pkg 安装
# pkg install podman-suite使用 Ports 安装:
# cd /usr/ports/sysutils/podman-suite/
# make install clean查看安装后配置:
root@ykla:~ # pkg info -D podman
podman-5.3.2_2:
On install: # 安装时:
The FreeBSD port of the Podman container engine is experimental and should be
used for evaluation and testing purposes only.
# Podman 容器引擎的 FreeBSD 移植版本是实验性的,仅供评估和测试使用。
$ sudo podman run --rm quay.io/dougrabson/hello
Podman can restart containers after a host is rebooted. To enable this, use:
# Podman 可以在主机重启后重新启动容器。要启用此功能,请执行:
$ sudo sysrc podman_enable=YES
and start the container with a restart policy:
# 并以重启策略启动容器:
$ sudo podman run -d --restart=always myimage
It is possible to run many Linux container images using FreeBSD's Linux emulation:
# 可以使用 FreeBSD 的 Linux 仿真功能运行许多 Linux 容器镜像:
$ sudo sysrc linux_enable=YES
$ sudo service linux start
$ sudo podman run --rm --os=linux alpine cat /etc/os-release | head -1
NAME="Alpine Linux"
On upgrade from podman<4.7.1: # 从 podman 小于 4.7.1 的版本升级时:
In Podman-4.7.0 and later, registry authentication creds moved from
/run/containers/0/auth.json to /root/.config/containers/auth.json. Either move
the file to the new location or just re-authenticate to the required registries.
# 在 Podman 4.7.0 及更高版本中,注册表认证凭据的位置已从
# /run/containers/0/auth.json 移动到了 /root/.config/containers/auth.json。
# 可以将该文件移动到新位置,或重新登录所需的镜像注册表。配置 fstab
将下列行写入 /etc/fstab
然后执行下列命令使之立即生效:
配置网络
复制配置文件
编辑
/etc/pf.conf,将ix0替换为你当前使用的网卡,可使用命令ifconfig查看
启动 pf
创建 zfs 存储池
若你使用 zfs:
若你 不 使用 zfs:
启动服务
测试 Ubuntu 镜像
测试拉取 Ubuntu
查看当前拉取的镜像
打印系统版本(仅打印前 5 行)
进入容器
测试 FreeBSD 维护者打包的 nginx 容器
打开网页 http://ip:8080 即可浏览测试 nginx 页面。
更多用法
查看日志
查看运行状态
停止并删除容器
删除镜像(必须先删除引用的容器再删除镜像)
拉取 FreeBSD
参考文献
最后更新于
这有帮助吗?