docker manifest

描述管理 Docker 映象清單和清單列表
用法docker manifest COMMAND

實驗性

此命令是實驗性的。

實驗性功能旨在用於測試和反饋,因為它們的功能或設計可能會在版本之間未經警告而更改,或者在未來的版本中被完全刪除。

描述

docker manifest 命令本身不執行任何操作。要對清單或清單列表進行操作,必須使用其中一個子命令。

單個清單是關於映象的資訊,例如層、大小和摘要。docker manifest 命令還提供額外資訊,例如映象構建所針對的作業系統和架構。

清單列表是透過指定一個或多個(理想情況下是多個)映象名稱建立的映象層列表。然後,它可以像 docker pulldocker run 命令中的映象名稱一樣使用,例如。

理想情況下,清單列表是由功能相同但適用於不同作業系統/架構組合的映象建立的。因此,清單列表通常被稱為“多架構映象”。然而,使用者也可以建立一個清單列表,指向兩個映象——一個用於 AMD64 上的 Windows,另一個用於 AMD64 上的 Darwin。

manifest inspect

$ docker manifest inspect --help

Usage:  docker manifest inspect [OPTIONS] [MANIFEST_LIST] MANIFEST

Display an image manifest, or manifest list

Options:
      --help       Print usage
      --insecure   Allow communication with an insecure registry
  -v, --verbose    Output additional info including layers and platform

manifest create

Usage:  docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...]

Create a local manifest list for annotating and pushing to a registry

Options:
  -a, --amend      Amend an existing manifest list
      --insecure   Allow communication with an insecure registry
      --help       Print usage

manifest annotate

Usage:  docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST

Add additional information to a local image manifest

Options:
      --arch string               Set architecture
      --help                      Print usage
      --os string                 Set operating system
      --os-version string         Set operating system version
      --os-features stringSlice   Set operating system feature
      --variant string            Set architecture variant

manifest push

Usage:  docker manifest push [OPTIONS] MANIFEST_LIST

Push a manifest list to a repository

Options:
      --help       Print usage
      --insecure   Allow push to an insecure registry
  -p, --purge      Remove the local manifest list after push

使用不安全登錄檔

manifest 命令僅與登錄檔互動。因此,它無法查詢引擎以獲取允許的不安全登錄檔列表。為了讓 CLI 與不安全登錄檔互動,一些 docker manifest 命令具有 --insecure 標誌。對於每次查詢登錄檔的事務,例如 create,必須指定 --insecure 標誌。此標誌告訴 CLI,此登錄檔呼叫可以忽略安全問題,例如缺失或自簽名證書。同樣,在 manifest push 到不安全登錄檔時,必須指定 --insecure 標誌。如果未與不安全登錄檔一起使用,manifest 命令將無法找到符合預設要求的登錄檔。

示例

檢查映象的清單物件

$ docker manifest inspect hello-world
{
        "schemaVersion": 2,
        "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
        "config": {
                "mediaType": "application/vnd.docker.container.image.v1+json",
                "size": 1520,
                "digest": "sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57"
        },
        "layers": [
                {
                        "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
                        "size": 972,
                        "digest": "sha256:b04784fba78d739b526e27edc02a5a8cd07b1052e9283f5fc155828f4b614c28"
                }
        ]
}

檢查映象清單並獲取作業系統/架構資訊

docker manifest inspect 命令帶有一個可選的 --verbose 標誌,該標誌提供映象名稱(Ref),以及架構和作業系統(Platform)。

與其他接受映象名稱的 Docker 命令一樣,您可以帶標籤或不帶標籤,或透過摘要(例如 hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f)引用映象。

這是一個使用 --verbose 標誌檢查映象清單的示例

$ docker manifest inspect --verbose hello-world
{
        "Ref": "docker.io/library/hello-world:latest",
        "Digest": "sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f",
        "SchemaV2Manifest": {
                "schemaVersion": 2,
                "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
                "config": {
                        "mediaType": "application/vnd.docker.container.image.v1+json",
                        "size": 1520,
                        "digest": "sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57"
                },
                "layers": [
                        {
                                "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
                                "size": 972,
                                "digest": "sha256:b04784fba78d739b526e27edc02a5a8cd07b1052e9283f5fc155828f4b614c28"
                        }
                ]
        },
        "Platform": {
                "architecture": "amd64",
                "os": "linux"
        }
}

建立並推送清單列表

要建立清單列表,首先透過指定要包含在清單列表中的組成映象在本地 create 清單列表。請記住,這將推送到登錄檔,因此如果您想推送到 docker 登錄檔以外的登錄檔,您需要使用登錄檔名稱或 IP 和埠建立清單列表。這類似於標記映象並將其推送到外部登錄檔。

建立清單列表的本地副本後,您可以選擇性地對其進行 annotate。允許的註釋包括架構和作業系統(覆蓋映象的當前值)、作業系統功能和架構變體。

最後,您需要將清單列表 push 到所需的登錄檔。以下是這三個命令的描述,以及一個將它們組合在一起的示例。

$ docker manifest create 45.55.81.106:5000/coolapp:v1 \
    45.55.81.106:5000/coolapp-ppc64le-linux:v1 \
    45.55.81.106:5000/coolapp-arm-linux:v1 \
    45.55.81.106:5000/coolapp-amd64-linux:v1 \
    45.55.81.106:5000/coolapp-amd64-windows:v1

Created manifest list 45.55.81.106:5000/coolapp:v1
$ docker manifest annotate 45.55.81.106:5000/coolapp:v1 45.55.81.106:5000/coolapp-arm-linux --arch arm
$ docker manifest push 45.55.81.106:5000/coolapp:v1
Pushed manifest 45.55.81.106:5000/coolapp@sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf16b426 with digest: sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b
Pushed manifest 45.55.81.106:5000/coolapp@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f with digest: sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a
Pushed manifest 45.55.81.106:5000/coolapp@sha256:39dc41c658cf25f33681a41310372f02728925a54aac3598310bfb1770615fc9 with digest: sha256:df436846483aff62bad830b730a0d3b77731bcf98ba5e470a8bbb8e9e346e4e8
Pushed manifest 45.55.81.106:5000/coolapp@sha256:f91b1145cd4ac800b28122313ae9e88ac340bb3f1e3a4cd3e59a3648650f3275 with digest: sha256:5bb8e50aa2edd408bdf3ddf61efb7338ff34a07b762992c9432f1c02fc0e5e62
sha256:050b213d49d7673ba35014f21454c573dcbec75254a08f4a7c34f66a47c06aba

檢查清單列表

$ docker manifest inspect coolapp:v1
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 424,
         "digest": "sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b",
         "platform": {
            "architecture": "arm",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 424,
         "digest": "sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 425,
         "digest": "sha256:df436846483aff62bad830b730a0d3b77731bcf98ba5e470a8bbb8e9e346e4e8",
         "platform": {
            "architecture": "ppc64le",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 425,
         "digest": "sha256:5bb8e50aa2edd408bdf3ddf61efb7338ff34a07b762992c9432f1c02fc0e5e62",
         "platform": {
            "architecture": "s390x",
            "os": "linux"
         }
      }
   ]
}

推送到不安全登錄檔

這是一個使用已知的不安全登錄檔建立和推送清單列表的示例。

$ docker manifest create --insecure myprivateregistry.mycompany.com/repo/image:1.0 \
    myprivateregistry.mycompany.com/repo/image-linux-ppc64le:1.0 \
    myprivateregistry.mycompany.com/repo/image-linux-s390x:1.0 \
    myprivateregistry.mycompany.com/repo/image-linux-arm:1.0 \
    myprivateregistry.mycompany.com/repo/image-linux-armhf:1.0 \
    myprivateregistry.mycompany.com/repo/image-windows-amd64:1.0 \
    myprivateregistry.mycompany.com/repo/image-linux-amd64:1.0

$ docker manifest push --insecure myprivateregistry.mycompany.com/repo/image:tag
注意

註釋清單列表不需要 --insecure 標誌,因為註釋是針對本地儲存的清單列表副本。如果您在本地儲存的清單列表上執行 docker manifest inspect,也可以跳過 --insecure 標誌。請務必記住,引擎在 docker pull 時從不使用本地儲存的清單列表。

子命令

命令描述
docker manifest annotate向本地映象清單新增額外資訊
docker manifest create建立本地清單列表以進行註釋並推送到登錄檔
docker manifest inspect顯示映象清單或清單列表
docker manifest push將清單列表推送到儲存庫
docker manifest rm從本地儲存中刪除一個或多個清單列表