7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Dockerイメージが対応しているプラットフォーム(OS、CPUアーキテクチャ)を調べる

Posted at

2行まとめ

  • Docker、Docker Hubはマルチプラットフォーム(OS、CPUアーキテクチャ)に対応しています。
  • DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect <イメージ名>でDockerイメージが対応しているプラットフォームを確認できます。

1. 概要

 Docker、Docker Hubがマルチプラットフォーム(OS、CPUアーキテクチャ)に対応して久しいです。Dockerをインストールし、Dockerイメージさえ対応していれば、どのOS、どのCPUアーキテクチャでもdocker run hello-worldのようにDockerコンテナを起動できます。

 場合によっては、Dockerイメージが対応しているプラットフォームを確認したいこともあるでしょう。結論から言えば、以下のコマンドで確認できます。

DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect <イメージ名>

2. 環境

 動作を確認した環境は以下の通りです。

mac$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G103

mac$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:21:11 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

3. DOCKER_CLI_EXPERIMENTAL環境変数について

 docker manifestコマンドは、Docker CLI v19.03.8の時点では実験的な機能です。そのため、このコマンドを有効化するためには~/.docker/config.json{"experimental": "enabled"}を指定するか、環境変数DOCKER_CLI_EXPERIMENTALenabledを設定する必要があります。

 実験的機能が有効化されていない場合、以下の通りエラーになります。

mac$ docker manifest inspect hello-world:latest
docker manifest inspect is only supported on a Docker cli with experimental cli features enabled

4. 実行例

docker manifest inspectの実行例をいくつか示します。対応しているプラットフォームが出力されていることが確認できます。

4.1. hello-world:latest

mac$ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect hello-world:latest
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 524,
         "digest": "sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 525,
         "digest": "sha256:e5785cb0c62cebbed4965129bae371f0589cadd6d84798fb58c2c5f9e237efd9",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v5"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 525,
         "digest": "sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v7"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 525,
         "digest": "sha256:963612c5503f3f1674f315c67089dee577d8cc6afc18565e0b4183ae355fb343",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 527,
         "digest": "sha256:85dc5fbe16214366748ebe9d7cc73bc42d61d19d61fe05f01e317d278c2287ed",
         "platform": {
            "architecture": "386",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 525,
         "digest": "sha256:8aaea2a718a29334caeaf225716284ce29dc17418edba98dbe6dafea5afcda16",
         "platform": {
            "architecture": "ppc64le",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 525,
         "digest": "sha256:577ad4331d4fac91807308da99ecc107dcc6b2254bc4c7166325fd01113bea2a",
         "platform": {
            "architecture": "s390x",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1124,
         "digest": "sha256:468a2702c410d84e275ed28dd0f46353d57d5a17f177aa7c27c2921e9ef9cd0e",
         "platform": {
            "architecture": "amd64",
            "os": "windows",
            "os.version": "10.0.17763.1098"
         }
      }
   ]
}

4.2. ubuntu:18.04

mac$ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect ubuntu:18.04
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:e5dd9dbb37df5b731a6688fa49f4003359f6f126958c9c928f937bec69836320",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:3b029ac9aa8eb5dffd43bb7326891cf64f9c228b3960cec55a56605d2ae2ad42",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v7"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:12b9106d200061c8eb2179c984e63cc17d5a4e7a34f6e9ad03360b8efe492e96",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:3e6b4be46d13e13127671a6f2bb848aec9125d6a389d012b2469721b89073b94",
         "platform": {
            "architecture": "386",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:705518497e5e3dd432fbfecec0ed1658947ff1e5068c266d42868bd3eb4a5a59",
         "platform": {
            "architecture": "ppc64le",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1152,
         "digest": "sha256:fbbc16efb3db29132a98651f0499467fbb4cea315d57aaf13397a2c2e68a09d0",
         "platform": {
            "architecture": "s390x",
            "os": "linux"
         }
      }
   ]
}

5. 最後に

 ARM64(AArch64)が勢いを増す今日この頃、マルチアーキテクチャ対応のDockerイメージが充実してくることを願っています!

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?