• 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 machine

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

OSTree 开发者最近的工作改变了局面。OSTree 现在能够从 OCI 镜像的内容中进行 rebase。更好的是,可以使用简单的 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 

现在镜像已经构建完成,您有两种使用镜像的选项。如果您需要多次使用新镜像或与他人共享,最好按照选项 1 中所述将镜像推送到 quay.io 等镜像仓库。否则,选项 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

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

/

留下回复

订阅

输入您的电子邮件地址以接收来自本网站的电子邮件更新。

返回

您的消息已发送

警告
警告
警告。

分类


搜索