Container:Development
(重定向自 )
开发和贡献
社区
- 邮件列表 - opensuse-kubic@opensuse.org
- #kubic @ irc.freenode.net
- Open Build System 项目
devel:kubic:containers 分支项目
让我们从创建 devel:kubic:containers 的分支项目并将其提取到您的本地工作站开始
mkdir obs cd obs for image in $(osc ls devel:kubic:containers); do osc bco devel:kubic:containers $image; done cd home\:*:branches:devel:kubic:containers
构建镜像
如果您想构建容器镜像,请转到其中一个子目录并执行 osc build container 命令。例如
cd kubic-multus-image osc build container
创建新镜像
新镜像的名称应遵循命名约定:kubic-$name-image。
假设您想创建一个名为 `foobar` 的镜像。从在 OBS 上创建“包”开始
osc mkpac kubic-foobar-image
每个镜像包含以下文件
_service- 一个配置 OBS 服务的的文件kubic-$name-image.changes- 一个由osc vc命令创建和更新的 changelog 文件kubic-$name-image.kiwi- 一个 KIWI 文件,定义镜像 - 元数据、要安装的软件包等。
让我们从创建 kubic-$name-image.kiwi 文件开始。假设我们想在该镜像中安装一个 foobar RPM 包,并且我们想默认执行 /usr/bin/foobar 命令,则内容应如下所示
<?xml version="1.0" encoding="utf-8"?>
<!-- OBS-ExcludeArch: i586 s390 -->
<image schemaversion="6.5" name="kubic-foobar-image" xmlns:suse_label_helper="com.suse.label_helper">
<description type="system">
<author>Thorsten Kukuk</author>
<contact>kukuk@suse.com</contact>
<specification>Foobar application</specification>
</description>
<preferences>
<type
image="docker"
derived_from="obsrepositories:/opensuse/busybox#latest">
<containerconfig
name="kubic/foobar"
tag="latest"
additionaltags="%PKG_VERSION%,%PKG_VERSION%-%RELEASE%"
maintainer="Thorsten Kukuk <kukuk@suse.com>">
<entrypoint execute="/usr/bin/foobar"/>
<labels>
<suse_label_helper:add_prefix prefix="org.opensuse.kubic.foobar">
<label name="org.opencontainers.image.title" value="openSUSE Kubic foobar container"/>
<label name="org.opencontainers.image.description" value="Image containing foobar for openSUSE Kubic."/>
<label name="org.opencontainers.image.version" value="%PKG_VERSION%-%RELEASE%"/>
<label name="org.opencontainers.image.created" value="%BUILDTIME%"/>
<label name="org.opensuse.reference" value="registry.opensuse.org/kubic/foobar:%PKG_VERSION%-%RELEASE%"/>
<label name="org.openbuildservice.disturl" value="%DISTURL%"/>
</suse_label_helper:add_prefix>
</labels>
<history author="Thorsten Kukuk <kukuk@suse.com>">openSUSE Kubic foobar container</history>
</containerconfig>
</type>
<version>3.0.0</version>
<packagemanager>zypper</packagemanager>
<rpm-check-signatures>false</rpm-check-signatures>
<rpm-excludedocs>true</rpm-excludedocs>
<locale>en_US</locale>
<keytable>us.map.gz</keytable>
<hwclock>utc</hwclock>
</preferences>
<repository>
<source path="obsrepositories:/"/>
</repository>
<packages type="bootstrap">
<package name="foobar"/>
</packages>
</image>
容器镜像版本控制的常用约定是使用容器化软件的版本作为镜像标签和版本。在我们的例子中,这意味着 foobar 镜像应该具有来自 foobar 包版本的容器版本和标签。
为了自动化该过程,创建一个包含以下内容的 _service
<services>
<service mode="buildtime" name="kiwi_metainfo_helper"/>
<service name="replace_using_package_version" mode="buildtime">
<param name="file">kubic-foobar-image.kiwi</param>
<param name="regex">%PKG_VERSION%</param>
<param name="parse-version">patch</param>
<param name="package">foobar</param>
</service>
<service mode="buildtime" name="kiwi_label_helper"/>
</services>
最后,让我们使用以下命令添加一个 changelog 文件条目
osc vc
通常,第一个 changelog 条目是 - Initial release。
之后,检查镜像是否构建成功
osc build container
如果构建成功,提交您的更改并提交到 devel:kubic:containers
osc submitrequest home:$user:branched:devel:kubic:containers kubic-foobar-image devel:kubic:containers kubic-foobar-image
: