nerdctl介绍
nerdctl is a command line interface for containerd
nerdctl安装
# wget https://github.com/containerd/nerdctl/releases/download/v1.5.0/nerdctl-1.5.0-linux-amd64.tar.gz
# tar xf nerdctl-1.5.0-linux-amd64.tar.gz -C /usr/local/bin/
# nerdctl version
WARN[0000] unable to determine buildctl version: exec: "buildctl": executable file not found in $PATH
Client:
Version: v1.5.0
OS/Arch: linux/amd64
Git commit: b33a58f288bc42351404a016e694190b897cd252
buildctl:
Version:
Server:
containerd:
Version: v1.7.5
GitCommit: fe457eb99ac0e27b3ce638175ef8e68a7d2bc373
runc:
Version: 1.1.9
GitCommit: v1.1.9-0-gccaecfcb
nerdctl使用
使用nerdctl登录dockerhub
默认登录dockerhub
# nerdctl login
Enter Username: nextgomsb
Enter Password: 输入密码
WARNING: Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
# nerdctl logout
Removing login credentials for https://index.docker.io/v1/
使用nerdctl登录非安全的harbor
[root@c1 ~]# nerdctl login -u admin www.kubemsb.com
Enter Password:
WARNING: Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
在harbor服务器上传容器镜像
[root@harbor ~]# docker pull nginx:latest
[root@harbor ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
......
nginx latest eea7b3dcba7e 2 weeks ago 187MB
[root@harbor ~]# docker tag nginx:latest www.kubemsb.com/library/nginx:latest
[root@harbor ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
......
nginx latest eea7b3dcba7e 2 weeks ago 187MB
www.kubemsb.com/library/nginx latest eea7b3dcba7e 2 weeks ago 187MB
[root@harbor harbor]# docker login www.kubemsb.com
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@harbor harbor]# docker push www.kubemsb.com/library/nginx:latest
使用nerdctl下载容器镜像
[root@c1 ~]# nerdctl pull www.kubemsb.com/library/nginx:latest
www.kubemsb.com/library/nginx:latest: resolved |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35: done |++++++++++++++++++++++++++++++++++++++|
config-sha256:eea7b3dcba7ee47c0d16a60cc85d2b977d166be3960541991f3e6294d795ed24: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:da761d9a302b21dc50767b67d46f737f5072fb4490c525b4a7ae6f18e1dbbf75: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:52d2b7f179e32b4cbd579ee3c4958027988f9a8274850ab0c7c24661e3adaac5: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:fd9f026c631046113bd492f69761c3ba6042c791c35a60e7c7f3b8f254592daa: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:055fa98b43638b67d10c58d41094d99c8696cc34b7a960c7a0cc5d9d152d12b3: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:96576293dd2954ff84251aa0455687c8643358ba1b190ea1818f56b41884bdbd: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:a7c4092be9044bd4eef78f27c95785ef3a9f345d01fd4512bc94ddaaefc359f4: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:e3b6889c89547ec9ba653ab44ed32a99370940d51df956968c0d578dd61ab665: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 2.9 s total: 67.2 M (23.2 MiB/s)
[root@c1 ~]# nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
www.kubemsb.com/library/nginx latest 48a84a0728ca About a minute ago linux/amd64 188.9 MiB 67.2 MiB
使用nerdctl上传容器镜像
[root@c1 ~]# nerdctl tag www.kubemsb.com/library/nginx:latest www.kubemsb.com/library/nginx:v1
[root@c1 ~]# nerdctl images
REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE
www.kubemsb.com/library/nginx latest 48a84a0728ca 3 minutes ago linux/amd64 188.9 MiB 67.2 MiB
www.kubemsb.com/library/nginx v1 48a84a0728ca 11 seconds ago linux/amd64 188.9 MiB 67.2 MiB
[root@c1 ~]# nerdctl push www.kubemsb.com/library/nginx:v1
INFO[0000] pushing as a reduced-platform image (application/vnd.docker.distribution.manifest.v2+json, sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35)
manifest-sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35: done |++++++++++++++++++++++++++++++++++++++|
config-sha256:eea7b3dcba7ee47c0d16a60cc85d2b977d166be3960541991f3e6294d795ed24: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 0.1 s