Docker创建manifest镜像

2023-10-18 12:49:11 浏览数 (2)

构建镜像

首先在 amd64 机器构建 lovelonger**/**perf-test:amd 镜像,然后在 arm64 机器构建 lovelonger/perf-test:arm 镜像,构建完成 push 到 dockerhub。

需要注意的是,manifest文件仅仅是针对于已经在仓库中的镜像!!! 换句话说,就是这个镜像是刚从仓库中pull下来的!如果这个镜像是自己build的,需要先push到仓库中,否则,这个镜像是没有manifest文件的!!同样的,如果你pull了一个镜像,tag了一下,再去看这个manifest文件,也是没有的,因为tag后的镜像不在镜像仓库中。

创建 manifest 列表

1 2 3 4

# docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...] # docker manifest create lovelonger/perf-test lovelonger/perf-test:amd lovelonger/perf-test:arm

当要修改一个 manifest列表时,可以加入 -a--amend参数。

设置 manifest 列表

1 2 3 4 5 6 7 8

# docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST # docker manifest annotate lovelonger/perf-test lovelonger/perf-test:amd --os linux --arch amd64 # docker manifest annotate lovelonger/perf-test lovelonger/perf-test:arm --os linux --arch arm64 --variant v8

查看 manifest 列表

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

# docker manifest inspect lovelonger/perf-test # docker manifest inspect lovelonger/perf-test { "schemaVersion": 2, "mediaType": "application/vnd.docker.distribution.manifest.list.v2 json", "manifests": [ { "mediaType": "application/vnd.docker.distribution.manifest.v2 json", "size": 947, "digest": "sha256:975589cae8ea492aac12a29d11cf31578a45ca92c32b599ac1030890d9f1e66a", "platform": { "architecture": "amd64", "os": "linux" } }, { "mediaType": "application/vnd.docker.distribution.manifest.v2 json", "size": 947, "digest": "sha256:d6bc0f26dc4d8746e7b60df59269c66840e4681f8af613d1da9b16884e402133", "platform": { "architecture": "arm64", "os": "linux", "variant": "v8" } } ] }

推送 manifest 列表

1

# docker manifest push lovelonger/perf-test

推送后可以在 dockerhub 看到详情

测试

x84_64 机器上面测试

1 2 3 4 5 6 7 8 9 10

# docker run -ti --rm lovelonger/perf-test:latest echo ;uname -a Unable to find image 'lovelonger/perf-test:latest' locally latest: Pulling from lovelonger/perf-test 2408cc74d12b: Pull complete 9d980ba59630: Pull complete a036d2a6b4b7: Pull complete Digest: sha256:df7c8738c9d7e3ce5058c90dd7b68dce874e4f454ee09bc28edc2727902c6ba5 Status: Downloaded newer image for lovelonger/perf-test:latest Linux crawler-sel 5.13.0-1027-oracle #32~20.04.1-Ubuntu SMP Fri Apr 15 05:59:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

arm64 机器上面测试

1 2 3 4 5 6 7 8 9 10

# docker run -ti --rm lovelonger/perf-test:latest echo ;uname -a Unable to find image 'lovelonger/perf-test:latest' locally latest: Pulling from lovelonger/perf-test b3c136eddcbf: Already exists abd313fa511b: Pull complete a036d2a6b4b7: Pull complete Digest: sha256:df7c8738c9d7e3ce5058c90dd7b68dce874e4f454ee09bc28edc2727902c6ba5 Status: Downloaded newer image for lovelonger/perf-test:latest Linux fc17e6a10e93 5.13.0-1021-oracle #26~20.04.1-Ubuntu SMP Mon Mar 7 14:30:17 UTC 2022 aarch64 Linux

0 人点赞