准备工作

  1. 确保Docker已安装(19.03+版本)
  2. 登录Harbor仓库:docker login your-harbor.com

步骤

1. 拉取基础镜像

# AMD64架构
docker pull eclipse-temurin:17-jdk-jammy --platform=linux/amd64
docker tag eclipse-temurin:17-jdk-jammy your-harbor.com/library/jdk17:amd64

# ARM64架构
docker pull eclipse-temurin:17-jdk-jammy --platform=linux/arm64
docker tag eclipse-temurin:17-jdk-jammy your-harbor.com/library/jdk17:arm64

2. 推送单架构镜像

docker push your-harbor.com/library/jdk17:amd64
docker push your-harbor.com/library/jdk17:arm64

3. 创建多架构manifest

docker manifest create your-harbor.com/library/jdk17:multiarch \
  your-harbor.com/library/jdk17:amd64 \
  your-harbor.com/library/jdk17:arm64

4. 推送manifest

docker manifest push your-harbor.com/library/jdk17:multiarch

5. 验证(无需实际运行)

docker manifest inspect your-harbor.com/library/jdk17:multiarch

验证输出示例

成功时应该看到类似输出:

{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1783,
         "digest": "sha256:...",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1783,
         "digest": "sha256:...",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

注意事项

  1. 确保Harbor仓库已存在(或设置为允许自动创建)
  2. 推送前必须对每个架构镜像单独打tag并推送
  3. manifest操作不需要额外的QEMU或buildx配置

标签: docker, harbor

评论已关闭