下载
需要注意本文学习了很多如下网站的内容:
https://zhuanlan.zhihu.com/p/366671300
# 第一步下载资源
https://github.com/moby/buildkit/releases/tag/v0.11.2
注意这是 2023.2.7 左右能够下载的最新版本
https://github.com/containerd/containerd/releases
注意这个可以下载cri-containerd的版本, 有一个集成的systemd服务便于使用.
部署服务-containerd
tar -zxvf cri-containerd-1.6.16-linux-amd64.tar.gz -C /
# 如果是arm的
tar -zxvf cri-containerd-1.6.16-linux-arm64.tar.gz -C /
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
# 启动服务即可
systemctl daemon-reload
systemctl enable containerd
systemctl start containerd
systemctl status containerd
部署服务-其他软件
# 注意这一步也需要在github上面下载对应文件
https://github.com/containerd/nerdctl
https://github.com/containernetworking/plugins
tar -zxvf nerdctl-1.2.0-linux-amd64.tar.gz -C /usr/local/bin/
tar -zxvf cni-plugins-linux-amd64-v1.2.0.tgz -C /usr/local/bin/
# 如果是arm的
tar -zxvf nerdctl-1.2.0-linux-arm64.tar.gz -C /usr/local/bin/
tar -zxvf cni-plugins-linux-arm64-v1.2.0.tgz -C /usr/local/bin/
部署服务-buildkit
注意下载的文件为:
buildkit-v0.11.2.linux-amd64.tar.gz
tar -zxvf buildkit-v0.11.2.linux-amd64.tar.gz -C /usr/local
# 如果是arm的
tar -zxvf buildkit-v0.11.2.linux-arm64.tar.gz -C /usr/local
# 创建配置文件
cat >/etc/systemd/system/buildkitd.service <<EOF
[Unit]
Description=BuildKit
Documentation=https://github.com/moby/buildkit
After=containerd.service
[Service]
Type=notify
ExecStart=/usr/local/bin/buildkitd --oci-worker=false --containerd-worker=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl restart buildkitd
systemctl enable buildkitd
systemctl status buildkitd
参数设置以及镜像处理
跟之前打包 openJdk的镜像一样, 增加文件信息:
root@inspur-PC:/docker-jdk# tree -L 1
.
├── dockerfile_openjdk字体
├── myfonts.tar.gz
└── zh.tar.gz
dockerfile的内容为:
FROM adoptopenjdk:8u292-b10-jdk-hotspot
RUN apt-get update && apt-get -y install fontconfig && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ && localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8
WORKDIR /usr/share/fonts/
ADD myfonts.tar.gz /usr/share/fonts/
RUN fc-cache
ADD zh.tar.gz /usr/lib/locale
ENV LANG zh_CN.utf8
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
buildctl build \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,name=openjdk_8_292_withfonts
修改镜像的命名空间
mkdir -p /etc/buildkit/
vim /etc/buildkit/buildkitd.toml
[worker.oci]
enabled = false
[worker.containerd]
enabled = true
# namespace should be "k8s.io" for Kubernetes (including Rancher Desktop)
namespace = "k8s.io"
platforms = [ "linux/arm64" ]
gc = true
# gckeepstorage sets storage limit for default gc profile, in MB.
gckeepstorage = 9000
重新构建镜像
- 会比docker构建多很多信息
- 注意我的多架构构建好像有点问题.
[root@KylinV10SP3ARM64 docker-jdk]# buildctl build \
> --frontend=dockerfile.v0 \
> --local context=. \
> --local dockerfile=. \
> --output type=image,name=openjdk_8_292_withfonts
[+] Building 184.3s (12/12) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 786B 0.0s
=> [internal] load metadata for docker.io/library/adoptopenjdk:8u292-b10-jdk-hotspot
查看镜像以及高阶应用
ctr -n buildkit i ls
# 打包的同事直接进行推送
buildctl build \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,name=docker.io/username/image:tag,push=true
--export-cache type=inline
问题解决
我使用UOS1050D 进行安装时出现了错误提示:
error: failed to solve: process "/bin/sh -c apt-get update && apt-get -y install fontconfig && apt-get install -y locales
&& rm -rf /var/lib/apt/lists/* \\ && localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8" did not complete successfully:
failed to create shim task: OCI runtime create failed: unable to retrieve OCI runtime error
(open /run/containerd/io.containerd.runtime.v2.task/k8s.io/5p0ndy0d0u5990sjt2r6lnujt/log.json: no such file or directory):
runc did not terminate successfully: exit status 127: unknown
根据百度怀疑是没有安装libseccomp 后者是版本太低导致.
查了下. 自动安装的版本是 libseccomp 2.3.x的版本
最低要求好像是 2.5.x
libseccomp-dev 已经是最新版 (2.3.3.2-1+dde)。
libseccomp2 已经是最新版 (2.3.3.2-1+dde)。
libseccomp2-dbgsym 已经是最新版 (2.3.3.2-1+dde)。
准备改天升级一下此包
但是我同时发现. 使用银河麒麟V10SP3自动就带的符合要求的就非常顺畅了.
标签:tar,--,containerd,gz,学习,buildkit,usr,简单,local
From: https://www.cnblogs.com/jinanxiaolaohu/p/17111257.html