首页 > 其他分享 >nerdctl build -- command to build container image from docker file

nerdctl build -- command to build container image from docker file

时间:2024-02-01 18:45:23浏览次数:29  
标签:knative container -- MiB buildkit build buildkitd sha256 extracting

1. Prerequisite of using nerdctl build

buildctl needs to be installed and buildkitd needs to be running.

2. check if buildctl installed

$ nerdctl version

Client:
Version: v1.7.2
OS/Arch: linux/amd64
Git commit: e32c4b023bf41e5c8325cfb893a53cefb5fc68ed
buildctl:
Version: v0.12.4
GitCommit: 833949d0f7908608b00ab6b93b8f92bdb147fcca

Server:
containerd:
Version: v1.7.11
GitCommit: 64b8a811b07ba6288238eefc14d898ee0b5b99ba
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0f
(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$

If buildctl version shown in the output, buildctl has been installed.

3. check if buildkitd is running

systemctl status buildkitd

4. if buildkitd is not running, start it.

$ sudo systemctl daemon-reload
$ sudo systemctl start buildkitd
$ systemctl enable buildkitd

Created symlink /etc/systemd/system/multi-user.target.wants/buildkitd.service → /lib/systemd/system/buildkitd.service.

If Error: Unit xxx not found, this is due to there is no files buildkitd.service and buildkit.socket, create them:

$ sudo gedit /lib/systemd/system/buildkit.socket

# file /lib/systemd/system/buildkit.socket
[Unit]
Description=BuildKit
Documention=https://github.com/moby/buildkit

[Socket]
ListenStream=%t/buildkit/buildkitd.sock

[Install]
WantedBy=sockets.target

$ sudo gedit /lib/systemd/system/buildkitd.service 

# file /lib/systemd/system/buildkitd.service
[Unit]
Description=BuildKit
Require=buildkit.socket
After=buildkit.socket
Documention=https://github.com/moby/buildkit

[Service]
ExecStart=/usr/local/bin/buildkitd --oci-worker=false --containerd-worker=true

[Install]
WantedBy=multi-user.target

Then, start buildkitd again:

$ sudo systemctl daemon-reload
$ sudo systemctl start buildkitd
$ systemctl enable buildkitd

Created symlink /etc/systemd/system/multi-user.target.wants/buildkitd.service → /lib/systemd/system/buildkitd.service.

# check status of buildkitd
$ systemctl status buildkitd

● buildkitd.service - BuildKit
Loaded: loaded (/lib/systemd/system/buildkitd.service; enabled; vendor preset:>
Active: active (running) since Thu 2024-02-01 15:16:41 CST; 1min 35s ago
Main PID: 1505075 (buildkitd)
Tasks: 10 (limit: 14115)
Memory: 9.1M
CPU: 86ms
CGroup: /system.slice/buildkitd.service
└─1505075 /usr/local/bin/buildkitd --oci-worker=false --

5. use sudo nerdctl build to build container image from docker file

$ sudo nerdctl build --no-cache -t tf_std_server:v1 -f Dockerfile.tf_std_server .

(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$ sudo nerdctl build --no-cache -t tf_std_server:v1 -f Dockerfile.tf_std_server .
[+] Building 3741.3s (7/7) FINISHED
=> [internal] load build definition from Dockerfile.tf_std_server 0.9s
=> => transferring dockerfile: 158B 0.0s
=> [internal] load metadata for docker.io/tensorflow/tensorflow:nightly-gpu 6.0s
=> [internal] load .dockerignore 0.6s
=> => transferring context: 2B 0.0s
=> [internal] load build context 1.9s
=> => transferring context: 1.31kB 0.0s
=> [1/2] FROM docker.io/tensorflow/tensorflow:nightly-gpu@sha256:1b9d78ea53e00988bdec6b89213eb967a823e5eb2a59e34a7ddd2c3825b576ce 3132.2s
=> => resolve docker.io/tensorflow/tensorflow:nightly-gpu@sha256:1b9d78ea53e00988bdec6b89213eb967a823e5eb2a59e34a7ddd2c3825b576ce 1.1s
=> => sha256:e74c2cb8c2daf8e7f20d5c89e649b54d2c55ff6fe38c4d0698a14bd979546661 1.13kB / 1.13kB 4.1s
=> => sha256:6fa98202cc0d88496208a0fb5ca9bdf65c58b2a3df21e5882af7f1fa77ac4796 1.13kB / 1.13kB 4.1s
=> => sha256:09e20d668ae0282f2cf36cbd038ef657d3f620267292309ff0a71abb2e6362d9 6.90kB / 6.90kB 3.6s
=> => sha256:680a80bd788865a81a4b5753812be435249c2a85293fe9a6f0c5a293cb51282d 808B / 808B 3.9s
=> => sha256:c139eef115d10483c12436d45f5dadff21efe04a603e1792ddf16e2ea220320d 677.26MB / 677.26MB 284.0s
=> => sha256:a856c4f368bad9ccac8ddc08d73d5ebe5082898a014574420ca282c926a8dab2 37.29MB / 37.29MB 9.9s
=> => sha256:891cf252afe9c3f25eda3c50f6f4aaf4016077f22c4d78b7f87a8649ae510038 127B / 127B 0.8s
=> => sha256:f76680bdaf18ce22d0dc71b099ab8fe2147e37d261c9dc89fa29c6403a17f2f8 972B / 972B 1.2s
=> => sha256:97f009b3c181c6c5514409f3ef1058a8b04a7bf26cde998f566bb7539b557a02 2.98GB / 2.98GB 2504.7s
=> => sha256:3a6e10d7e4e9856303c630329324340a5591b82307737246695c61f798fc45f5 34.87MB / 34.87MB 9.9s
=> => sha256:0bbef35c2ff6cdf194eaecae34a64b8e9fb75694d8e502c7c88c390f8800d355 397B / 397B 0.6s
=> => sha256:5c851b555cd4eeb945c7fc1830dd86f14d070d4fd6ec879736b2df26b0871ecf 769B / 769B 1.2s
=> => sha256:82f3a5f8eeeeadbd27d8ba158b561036f5d49010507b2bf5ff7771d3002fa0db 861B / 861B 0.7s
=> => sha256:7d4f0f8effa7864e2b25cac47ecb80e71881841ce2b2a32d9e4c06d5696635b5 6.88kB / 6.88kB 0.8s
=> => sha256:89aa5c6f87943c439cf2ceb52a6b13506ea6a1e614d14570b407ae3dfeede332 0B / 185B 3705.3s
=> => sha256:d1937dd2edf2b94d5f600d1112c804645e3d345cb93bf15444910612534f1f41 57.07MB / 57.07MB 14.4s
=> => sha256:03bb9eb021f579ed871d5fee2344ba68d4509e9fc3b8865cf47fad506fa2f5d7 4.62MB / 4.62MB 2.2s
=> => sha256:aece8493d3972efa43bfd4ee3cdba659c0f787f8f59c82fb3e48c87cbb22a12e 29.54MB / 29.54MB 7.7s
=> => extracting sha256:aece8493d3972efa43bfd4ee3cdba659c0f787f8f59c82fb3e48c87cbb22a12e 3.6s
=> => extracting sha256:03bb9eb021f579ed871d5fee2344ba68d4509e9fc3b8865cf47fad506fa2f5d7 0.9s
=> => extracting sha256:d1937dd2edf2b94d5f600d1112c804645e3d345cb93bf15444910612534f1f41 3.1s
=> => extracting sha256:89aa5c6f87943c439cf2ceb52a6b13506ea6a1e614d14570b407ae3dfeede332 0.4s
=> => extracting sha256:7d4f0f8effa7864e2b25cac47ecb80e71881841ce2b2a32d9e4c06d5696635b5 0.3s
=> => extracting sha256:82f3a5f8eeeeadbd27d8ba158b561036f5d49010507b2bf5ff7771d3002fa0db 0.3s
=> => extracting sha256:5c851b555cd4eeb945c7fc1830dd86f14d070d4fd6ec879736b2df26b0871ecf 0.4s
=> => extracting sha256:0bbef35c2ff6cdf194eaecae34a64b8e9fb75694d8e502c7c88c390f8800d355 0.6s
=> => extracting sha256:3a6e10d7e4e9856303c630329324340a5591b82307737246695c61f798fc45f5 3.3s
=> => extracting sha256:97f009b3c181c6c5514409f3ef1058a8b04a7bf26cde998f566bb7539b557a02 415.0s
=> => extracting sha256:f76680bdaf18ce22d0dc71b099ab8fe2147e37d261c9dc89fa29c6403a17f2f8 1.4s
=> => extracting sha256:891cf252afe9c3f25eda3c50f6f4aaf4016077f22c4d78b7f87a8649ae510038 3.1s
=> => extracting sha256:a856c4f368bad9ccac8ddc08d73d5ebe5082898a014574420ca282c926a8dab2 50.5s
=> => extracting sha256:c139eef115d10483c12436d45f5dadff21efe04a603e1792ddf16e2ea220320d 136.8s
=> => extracting sha256:680a80bd788865a81a4b5753812be435249c2a85293fe9a6f0c5a293cb51282d 0.6s
=> => extracting sha256:09e20d668ae0282f2cf36cbd038ef657d3f620267292309ff0a71abb2e6362d9 1.9s
=> => extracting sha256:6fa98202cc0d88496208a0fb5ca9bdf65c58b2a3df21e5882af7f1fa77ac4796 0.6s
=> => extracting sha256:e74c2cb8c2daf8e7f20d5c89e649b54d2c55ff6fe38c4d0698a14bd979546661 0.6s
=> [2/2] COPY tf_std_server.py / 22.8s
=> exporting to docker image format 534.1s
=> => exporting layers 5.8s
=> => exporting manifest sha256:5364a028bff0588fcd3b9a91489b64ba59d17fc390ef516bdd11d77db257e916 0.3s
=> => exporting config sha256:d39144c35ea9a32641039358493137fdbce32ee5688b2c307cf255d127e6a0ed 0.4s
=> => sending tarball 527.0s
error: failed to solve: DeadlineExceeded: context deadline exceeded
unpacking docker.io/library/tf_std_server:v1 (sha256:5364a028bff0588fcd3b9a91489b64ba59d17fc390ef516bdd11d77db257e916)...
Loaded image: docker.io/library/tf_std_server:v1
(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$

Attention:
need 'sudo' to run the command as root, or:

(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$ nerdctl build --no-cache -t tf_std_server:v1 -f Dockerfile.tf_std_server .
ERRO[0000] buildctl needs to be installed and buildkitd needs to be running, see https://github.com/moby/buildkit , and containerd-rootless-setuptool.sh install-buildkit for OCI worker or containerd-rootless-setuptool.sh install-buildkit-containerd for containerd worker error="failed to ping to host unix:///run/user/1000/buildkit-default/buildkitd.sock: exit status 1\nfailed to ping to host unix:///run/user/1000/buildkit/buildkitd.sock: exit status 1"
FATA[0000] no buildkit host is available, tried 2 candidates: failed to ping to host unix:///run/user/1000/buildkit-default/buildkitd.sock: exit status 1
failed to ping to host unix:///run/user/1000/buildkit/buildkitd.sock: exit status 1

6. sudo nerdctl images to check the image

(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$ sudo nerdctl images

[sudo] password for maye:
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
tf_std_server v1 5364a028bff0 2 hours ago linux/amd64 7.0 GiB 3.6 GiB
tensorflow/serving latest fdc296e313fa 4 weeks ago linux/amd64 526.3 MiB 138.7 MiB
gcr.io/ml-pipeline/metadata-writer 2.0.1 e0e652bb8d5e 8 weeks ago linux/amd64 1.1 GiB 390.6 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/activator c2994c2b6c2c 8 weeks ago linux/amd64 56.6 MiB 16.8 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/autoscaler 8319aa662b49 8 weeks ago linux/amd64 57.1 MiB 17.0 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/controller 98a2cc7fd62e 8 weeks ago linux/amd64 62.6 MiB 18.7 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/domain-mapping-webhook 7368aaddf2be 8 weeks ago linux/amd64 52.5 MiB 16.2 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/domain-mapping f66c41ad7a73 8 weeks ago linux/amd64 54.1 MiB 16.6 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/queue dabaecec3886 8 weeks ago linux/amd64 33.3 MiB 10.3 MiB
gcr.lank8s.cn/knative-releases/knative.dev/serving/cmd/webhook 4305209ce498 8 weeks ago linux/amd64 55.9 MiB 16.6 MiB
gcr.lank8s.cn/ml-pipeline/metadata-writer 2.0.1 e0e652bb8d5e 8 weeks ago linux/amd64 1.1 GiB 390.6 MiB
m.daocloud.io/gcr.io/ml-pipeline/metadata-envoy 2.0.0-alpha.7 a3e53e33c517 8 weeks ago linux/amd64 251.0 MiB 98.9 MiB
(base) maye@maye-Inspiron-5547:~/github_repository/tensorflow_ecosystem/distribution_strategy$

Attention:
need 'sudo' to run as root, or the image built by nerdctl build not shown.

标签:knative,container,--,MiB,buildkit,build,buildkitd,sha256,extracting
From: https://www.cnblogs.com/zhenxia-jiuyou/p/18001863

相关文章

  • 路由选择协议(学习笔记)
    一、概述路由选择协议分为静态路由选择和动态路由选择。静态路由是由人工配置的网络路由、默认路由、特定主机路由与黑洞路由。这种方式简单,开销小,但是并不能及时适应网络状态的变化,一般只在小规模网络中使用。动态路由指路由器通过路由选择协议自动获取路由器信息。比较复......
  • 10线性代数基础综合卷
    张宇基础卷线代发现很多问题,值得再做一遍3行变换是把E放到右方,列变换是把E放到下方。这道题求逆可以用穿脱原则解出来4首先记结论,AB=O则r(a)+r(b)<n,学会证明(解集的秩为n-r(a)),B是从解集中抽出来的;5根据秩的情况判断特征值,不满秩则一定有0特征值; 当可对角化时,零特征值所对应的特征......
  • 「杂文」日常9
    20240201春节池收工,286抽1铃兰1鸿雪1左乐1水月3黍,等用送的抽凑齐300换个大哥......
  • RunnerGo低代码测试体验
    RunnerGo是基于go语言自研的一款企业级全栈式测试平台,采用Apache-2.0license开源协议,涵盖接口测试、性能测试、UI测试和项目管理等功能,并独创“拖拉拽”的方式快速编排真实测试场景的功能,加速产品交付周期、保证产品交付质量,为企业测试团队和产研团队提供一站式解决方案,是目前市......
  • 软件测试/测试管理|项目启动:成功开启新征程的关键一步
    测试管理班是专门面向测试与质量管理人员的一门课程,通过提升从业人员的团队管理、项目管理、绩效管理、沟通管理等方面的能力,使测试管理人员可以更好的带领团队、项目以及公司获得更快的成长。提供1v1私教指导,BAT级别的测试管理大咖量身打造职业规划。在项目管理中,项目启动......
  • 软件测试/测试管理|需求管理:与产品经理沟通与解决不规范、不清晰和频繁变更的方法
    测试管理班是专门面向测试与质量管理人员的一门课程,通过提升从业人员的团队管理、项目管理、绩效管理、沟通管理等方面的能力,使测试管理人员可以更好的带领团队、项目以及公司获得更快的成长。提供1v1私教指导,BAT级别的测试管理大咖量身打造职业规划。在测试管理的角色中,与......
  • 介绍一个超好用的API管理工具:Apipost
    Apipost是一款集API调试、生成文档、Mock、测试于一体的协同工具。单个工具可以同时满足接口测试、生成/分享文档、Mock、流程测试等功能,还有超实用的多人多角色间实时协作的功能。将前端、后端、测试三种角色串联起来,从而实现工作流程无缝衔接、提高研发效率!Apipost的定位是:Pos......
  • ChatGPT 被曝泄露私密对话;美国 AI 企业一天蒸发 1.3 万亿市值丨 RTE 开发者日报 Vol.1
      开发者朋友们大家好: 这里是「RTE开发者日报」,每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享RTE(RealTimeEngagement)领域内「有话题的新闻」、「有态度的观点」、「有意思的数据」、「有思考的文章」、「有看点的会议」,但内容仅代表编辑......
  • mysql: error while loading shared libraries: libncurses.so.6: cannot open shared
    查找没有libncurses.so.5,可能有libncurses.so不同版本的文件,使用命令find/-name'libncurses*'复制+覆盖软链接先复制到lib64文件夹,再用软链接重新覆盖一下[root@lab-aliyunwzx]#cp/home/wll/miniconda3/lib/libncurses.so.6/lib64[root@lab-aliyunwzx]#cd/lib6......
  • 博客园markdown图片文档上传方法
    ###下载NET环境5.0下载链接:https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/sdk-5.0.408-windows-x64-installerdotnet-sdk-5.0.408-win-x64.exe注意是v5.0版本检查版本是否OK,无命令,安装.net5.0后检查。若不完整,检查环境变量路径。参考下面其他问题方法。......