https://www.jianshu.com/p/835179171609
buildkit 可执行文件: 下载地址
解压:tar -zxvf buildkit-v0.10.6.linux-amd64.tar.gz
复制到 /usr/bin
cp build/buildctl /usr/bin/
buildkit -version
buildkitd
到 /usr/bin
cp build/builkitd /usr/bin/
/usr/lib/systemd/system/buildkitd.service
文件:cat > /usr/lib/systemd/system/buildkitd.service <<EOF
[Unit]
Description=/usr/bin/buildkitd
ConditionPathExists=/usr/bin/buildkitd
After=containerd.service
[Service]
Type=simple
ExecStart=/usr/bin/buildkitd
User=root
Restart=on-failure
RestartSec=1500ms
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl restart buildkitd && systemctl enable buildkitd
验证运行状态
systemctl status buildkitd
未运行 buildkitd 之前:会报下面的错误:
[root@k8s0 cbbpa-server-utils]# nerdctl build -t test/testimage:0.0.1 .
ERRO[0000] `buildctl` needs to be installed and `buildkitd` needs to be running, see https://github.com/moby/buildkit error="2 errors occurred:\n\t* failed to ping to host unix:///run/buildkit-default/buildkitd.sock: exit status 1\n\t* failed to ping to host unix:///run/buildkit/buildkitd.sock: exit status 1\n\n"
FATA[0000] no buildkit host is available, tried 2 candidates: 2 errors occurred:
* failed to ping to host unix:///run/buildkit-default/buildkitd.sock: exit status 1
* failed to ping to host unix:///run/buildkit/buildkitd.sock: exit status 1
运行 buildkitd 执行:就跑通了:
[root@k8s0 cbbpa-server-utils]# systemctl start buildkitd
[root@k8s0 cbbpa-server-utils]# nerdctl build -t test/testimage:0.0.1 .
[+] Building 3.6s (9/9) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 256B 0.0s
=> [internal] load metadata for docker.io/library/busybox:latest 3.0s
=> [1/4] FROM docker.io/library/busybox@sha256:fcd85228d7a25feb59f101ac3a955d27c80df4ad824d65f5757a954831450185 0.0s
=> => resolve docker.io/library/busybox@sha256:fcd85228d7a25feb59f101ac3a955d27c80df4ad824d65f5757a954831450185 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 106B 0.0s
=> CACHED [2/4] WORKDIR /root 0.0s
=> CACHED [3/4] ADD cbbpa_server_utils.bin /root 0.0s
=> CACHED [4/4] RUN chmod -R 777 . 0.0s
=> exporting to oci image format 0.5s
=> => exporting layers 0.0s
=> => exporting manifest sha256:e2cc5478d2911b1ac660886ee53950997f89d05b3c5ffc6ca63653e0b64e0a58 0.0s
=> => exporting config sha256:3585a98666945a396c21d259885b61a922ff46d8db5b33dc111b7a0701d26744 0.0s
=> => sending tarball 0.4s
unpacking docker.io/test/testimage:0.0.1 (sha256:e2cc5478d2911b1ac660886ee53950997f89d05b3c5ffc6ca63653e0b64e0a58)...
Loaded image: docker.io/test/testimage:0.0.1[root@k8s0 cbbpa-server-utils]# date
Mon Nov 21 10:26:59 CST 2022