docker构建多CPU镜像

  1. 1. 概述
  2. 2. docker构建多CPU镜像基础
  3. 3. 开启image manifest编译功能
  4. 4. 创建多层镜像

docker构建多CPU镜像

1. 概述

docker镜像是分平台的,不同平台的镜像不同.
如果docker的linux/arm64镜像运行在linux/amd64上,会报错exec format error.

2. docker构建多CPU镜像基础

docker registry版本:v2.3+
docker 版本:1.10+

3. 开启image manifest编译功能

docker manifest的开启需要额外的配置,并且不能用于开发环境.

It should not be used in production environments.

配置docker的config.json文件

sudo vim .docker/config.json

添加"experimental": "enabled"

{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "a2Fpc2F3aW5kOjE5ODkwODEwTU1A"
        }
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/19.03.3 (linux)"
    },
    "experimental": "enabled"
}

4. 创建多层镜像

docker manifest create csedge/device-serial-go:1.1.0-dev csedge/device-serial-go:1.1.0-arm64-dev csedge/device-serial-go:1.1.0-amd64-dev

docker manifest annotate csedge/device-serial-go:1.1.0-dev csedge/device-serial-go:1.1.0-arm64-dev --os linux --arch arm64

docker manifest annotate csedge/device-serial-go:1.1.0-dev csedge/device-serial-go:1.1.0-amd64-dev --os linux --arch amd64

docker manifest push csedge/device-serial-go:1.1.0-dev

查看manifest文件

docker manifest inspect csedge/device-serial-go:1.1.0-dev
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 735,
         "digest": "sha256:cdcdfce4612155dbec008ac701652ae4136892da1989d4eeb24a4fa12912b8eb",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 735,
         "digest": "sha256:68644d08038f7add8cffc5c39688f47a23ff3cde0a92fb2ab163881be1bfe02d",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      }
   ]
}

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 wind.kaisa@gmail.com

文章标题:docker构建多CPU镜像

本文作者:kaisawind

发布时间:2019-12-20, 06:53:54

最后更新:2019-12-20, 06:53:54

原始链接:https://kaisawind.gitee.io/2019/12/19/2019-12-20-docker/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏