docker_practice/image/manifest.md

163 lines
5.6 KiB
Go
Raw Normal View History

# Docker -- docker manifest
使 Docker 宿 `Linux x86_64` 使 `Linux x86_64`
> WindowsmacOS 使 [binfmt_misc](https://docs.docker.com/docker-for-mac/multi-arch/) 提供了多种架构支持,在 Windows、macOS 系统上 (x86_64) 可以运行 arm 等其他架构的镜像。
`Linux x86_64` `username/test`
```docker
FROM alpine
CMD echo 1
```
Docker Hub `Linux arm64v8` 使
```bash
$ docker run -it --rm username/test
```
`Linux x86_64` `Linux arm64v8` `username/test` `username/arm64v8-test` 使
Docker
2021-03-11 23:09:37 +08:00
`Linux x86_64` `Linux arm64v8` 使 `golang:alpine` `$ docker run golang:alpine go version`
2021-03-11 23:09:37 +08:00
`golang:alpine` [`manifest` (`manifest list`)](https://docs.docker.com/registry/spec/manifest-v2-2/)。
Docker `manifest` Docker Docker `golang:alpine` `username/test`
使 `$ docker manifest inspect golang:alpine` `manifest`
```bash
$ docker manifest inspect golang:alpine
```
```json
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:5e28ac423243b187f464d635bcfe1e909f4a31c6c8bce51d0db0a1062bec9e16",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:2945c46e26c9787da884b4065d1de64cf93a3b81ead1b949843dda1fcd458bae",
"platform": {
"architecture": "arm",
"os": "linux",
"variant": "v7"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:87fff60114fd3402d0c1a7ddf1eea1ded658f171749b57dc782fd33ee2d47b2d",
"platform": {
"architecture": "arm64",
"os": "linux",
"variant": "v8"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:607b43f1d91144f82a9433764e85eb3ccf83f73569552a49bc9788c31b4338de",
"platform": {
"architecture": "386",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:25ead0e21ed5e246ce31e274b98c09aaf548606788ef28eaf375dc8525064314",
"platform": {
"architecture": "ppc64le",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1365,
"digest": "sha256:69f5907fa93ea591175b2c688673775378ed861eeb687776669a48692bb9754d",
"platform": {
"architecture": "s390x",
"os": "linux"
}
}
]
}
```
`manifest` `digest` Docker 使 `manifest` ( `golang:alpine`)
使 `$ docker manifest` `manifest` Docker Hub
##
`Linux x86_64` `username/x8664-test` `Linux arm64v8` `username/arm64v8-test` Docker Hub
## `manifest`
```bash
# $ docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...]
$ docker manifest create username/test \
username/x8664-test \
username/arm64v8-test
```
2021-03-11 23:09:37 +08:00
`manifest` `-a` `--amend`
## `manifest`
```bash
# $ docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST
$ docker manifest annotate username/test \
username/x8664-test \
--os linux --arch x86_64
$ docker manifest annotate username/test \
username/arm64v8-test \
--os linux --arch arm64 --variant v8
```
`manifest`
## `manifest`
```bash
$ docker manifest inspect username/test
```
## `manifest`
Docker Hub
```bash
$ docker manifest push username/test
```
##
`Linux x86_64` `Linux arm64v8` `$ docker run -it --rm username/test`
##
`manifest`
* https://www.docker.com/blog/multi-arch-all-the-things/