5.4. 使用 Go Toolset 创建基于 UBI 的自定义容器
Go Toolset 软件包是 Red Hat Universal Base Images (UBIs)存储库的一部分,这意味着您可以安装 Go Toolset 作为基础 UBI 容器镜像添加。要保持容器镜像大小小,请只安装单个软件包,而不是整个 Go Toolset。
或者,您可以安装 UBI Go Toolset 容器镜像来访问 Go Toolset。如需更多信息,请参阅 拉取基于 UBI 的 Go Toolset 容器镜像。
先决条件
- 现有容器文件。有关创建 Containerfiles 的详情,请参考 Dockerfile 参考 页面。
流程
要创建包含 Go Toolset 的容器镜像,请在容器文件中添加以下内容:
对于基于 RHEL 8 的镜像,请输入:
FROM registry.access.redhat.com/ubi8/ubi:latest RUN yum module install -y go-toolset
FROM registry.access.redhat.com/ubi8/ubi:latest RUN yum module install -y go-toolset
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 对于基于 RHEL 9 的镜像,请输入:
FROM registry.access.redhat.com/ubi9/ubi:latest RUN yum install -y go-toolset
FROM registry.access.redhat.com/ubi9/ubi:latest RUN yum install -y go-toolset
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 对于基于 RHEL 10 的镜像,请输入:
FROM registry.access.redhat.com/ubi10/ubi:latest RUN yum install -y go-toolset
FROM registry.access.redhat.com/ubi10/ubi:latest RUN yum install -y go-toolset
Copy to Clipboard Copied! Toggle word wrap Toggle overflow