M1 Macbook Pro Docker 问题 Gradle 和 JDK

时间:2021-02-22 15:39:07

标签: java macos docker gradle apple-m1

Docker 给出了这个错误,不知道在 M1 mac 上如何处理它,在这种情况下我如何利用虚拟化?其他docker镜像已经搭建成功,除了gradle。

Building platform
[+] Building 1.9s (5/5) FINISHED                                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                                   0.4s
 => => transferring dockerfile: 37B                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                      0.5s
 => => transferring context: 2B                                                                                                                                        0.0s
 => CANCELED [internal] load metadata for docker.io/library/java:8                                                                                                     1.2s
 => ERROR [internal] load metadata for docker.io/library/gradle:4.7.0-jdk8-alpine                                                                                      1.2s
 => [auth] library/gradle:pull token for registry-1.docker.io                                                                                                          0.0s
------
 > [internal] load metadata for docker.io/library/gradle:4.7.0-jdk8-alpine:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:588dcfb0c01babf0ed3989462f13600567e8c5325ea746122dea10717d0a7676: not found
ERROR: Service 'platform' failed to build

1 个答案:

答案 0 :(得分:0)

Gradle 4.7 版本太旧,无法支持 ARM。您至少需要将其更新到 Gradle v6.6。

检查 Gradle v4.7 的 docker 清单显示仅支持 amd64:

% docker manifest inspect gradle:4.7
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2630,
         "digest": "sha256:ac443afe3db5345443498323b231ebb24957db6eb9f60810e5a130ee0bfb816e",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      }
   ]
}

第一个支持 arm64 的 Gradle 版本是 v6.6:

% docker manifest inspect gradle:6.6
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2002,
         "digest": "sha256:3ead37e1c04f2e5e8c7a62d9f2d66fb8bc407e3bb5add60ced374ed1fd856384",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2001,
         "digest": "sha256:e73b629a0d1266be3a8a2f07f0247a4ad216999d4ea116c63d60abf65cded9a6",
         "platform": {
            "architecture": "arm",
            "os": "linux",
            "variant": "v7"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2002,
         "digest": "sha256:bd2e6141429a2c6a365637fe93c0c57908dda4c775fe4ca0d1e05b3019602fec",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2002,
         "digest": "sha256:2db090296416298ffc96fc9e75a51014976095e14d4445a4e0bfef6df77818cb",
         "platform": {
            "architecture": "ppc64le",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2001,
         "digest": "sha256:a93a6657249908eb6e4f9cf706649a73016ca0d73c5b6138a8556cea984961b2",
         "platform": {
            "architecture": "s390x",
            "os": "linux"
         }
      }
   ]
}