• Cartoon showing a light purple os-tree icon on the left and a dark purple gradiated os-tree icon on the right. a large purple arrow is pointing from the one on the left to the one on the right. the os-tree icon on the right has a septagon with the words OCI on it, representing an OCI contianer image modifying the os-tree it depicts. The podman selkie seals cartoon is inbetween the two icons under the arrow. The background is purple and the seals are in blue water.
, ,

使用 OSTree 定制 Podman 机器

开发者一直在询问我们如何定制 Podman 机器以添加或删除内容。直到最近,答案一直是使用 cosa 工具 来创建操作系统和 qcow 镜像。这个过程并不特别困难,但它确实有助于拥有快速的磁盘 I/O、快速的网络连接以及安装了 Podman 的裸机操作系统。

但是,OSTree 开发人员最近的工作改变了游戏规则。OSTree 现在能够从 OCI 镜像的内容中重新设置其自身。更棒的是,可以使用简单的 Containerfile 和 podman build 来构建镜像。对于 Podman 来说,这是一个完美的技术匹配,并将解决 Podman 机器中的一些持续存在的问题。

我们收到的最常见的定制请求是拥有一个包含最新 Podman 的镜像。在示例部分,我将提供使用 Fedora COPR Podman-Next 存储库(其中包含来自上游的最新版本的 Podman)的命令。

创建具有比默认资源更多的机器

$ podman machine init -m 4192 --cpus 4 --disk-size 30 –-now builder 

克隆 coreos 分层示例

$ git clone https://github.com/coreos/layering-examples

使用 podman 构建新镜像
 

$ cd layering-examples/podman-next 
$ podman build -t podman_next https://raw.githubusercontent.com/coreos/coreos-layering-examples/main/podman-next/Containerfile

SSH 登录机器

$ podman machine ssh builder 

现在镜像已经构建完成,您有两个选项来使用该镜像。如果您需要多次使用新镜像或与其他人共享,最好将镜像推送到像 quay.io 这样的镜像存储库中,如选项 1 所述。否则,选项 2 允许您在本地执行所有操作,并避免推送和重新拉取的网络使用。 

选项 1

$ podman tag localhost/podman_next quay.io/baude/podman_next 
$ sudo rpm-ostree --bypass-driver --experimental rebase ostree-unverified-registry:quay.io/baude/podman_next 

选项 2

$ skopeo copy containers-storage:localhost/podman_next oci:/var/tmp/podman_next 
$ sudo rpm-ostree --bypass-driver --experimental rebase ostree-unverified-image:oci:/var/tmp/podman_next

您现在必须重新启动机器才能使更改生效。

/

发表评论

订阅

使用您的电子邮件地址注册以接收来自本网站的电子邮件更新。


类别


搜索