跳转到内容
For the complete documentation index, see llms.txt. This page is also available as Markdown.

18.10.导入并运行容器

注意

目前,FreeBSD 上的所有 Podman 容器都必须以 root 身份运行,这是 FreeBSD jail 的要求。

在必要的工具和防火墙规则就位后,就可以从 FreeBSD Releases 获取官方发布的镜像,并根据情况选择 aarch64 或 amd64。

18.10.1. 导入 FreeBSD OCI 镜像

如上所述,虽然直接从公共容器注册表拉取镜像最为方便,但为了获得最强的信任链,请直接从 FreeBSD.org 下载镜像,并根据 PGP 签名的发行公告校验校验和。

# export OCIBASE=https://download.freebsd.org/releases/OCI-IMAGES/15.1-RELEASE/amd64/Latest
# podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-static.txz
Getting image source signatures
Copying blob 44defc6cee2e done   |
Copying config 5921c62e76 done   |
Writing manifest to image destination
Loaded image: localhost/freebsd-static:15.1-RELEASE-amd64

# podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-dynamic.txz
Getting image source signatures
Copying blob 6054dffc3887 done   |
Copying config 33427d59f9 done   |
Writing manifest to image destination
Loaded image: localhost/freebsd-dynamic:15.1-RELEASE-amd64

# podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-runtime.txz
Getting image source signatures
Copying blob dcbbfcb598fe done   |
Copying config 90c4936754 done   |
Writing manifest to image destination
Loaded image: localhost/freebsd-runtime:15.1-RELEASE-amd64

# podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-notoolchain.txz
Getting image source signatures
Copying blob a16c94176cc3 done   |
Copying config 086572f35c done   |
Writing manifest to image destination
Loaded image: localhost/freebsd-notoolchain:15.1-RELEASE-amd64

# podman load -i=$OCIBASE/FreeBSD-15.1-RELEASE-amd64-container-image-toolchain.txz
Getting image source signatures
Copying blob b04531b7d93d done   |
Copying config b927c11b2e done   |
Writing manifest to image destination
Loaded image: localhost/freebsd-toolchain:15.1-RELEASE-amd64

18.10.2. 列出镜像

注意,镜像 ID 每次都完全可复现,且 IMAGE ID 列与导入镜像时报告的哈希值一致。

18.10.3. 列出层

可以显示构成镜像的各层,由此可以看出 runtime 镜像由三个部分组成,每个部分本身即是一层:

18.10.4. 使用公共注册表

虽然最安全的来源是从官方 FreeBSD 发行版下载,但还有两个由 FreeBSD 发行团队和集群管理员团队管理的公共容器注册表。两者提供的镜像完全相同,但工作流更简单,也更贴合容器的使用方式。

18.10.5. 获取容器

可以使用 podman pull 从公共注册表获取镜像:

18.10.6. 运行容器

使用 podman run 启动容器。-it 选项分配一个交互式终端,--rm 在容器退出时将其删除。如果未指定命令,则使用镜像的默认入口:

也可以指定具体的命令:

由于容器镜像不包含内核,freebsd-version(1) 对运行中的内核与已安装的用户空间会显示不同的结果。本例中,15.0-RELEASE 容器运行在 15.1-RELEASE 主机上:

最后更新于