从0到1构建多架构镜像

前言

在软件开发领域中,构建跨平台应用程序已经成为了一个普遍存在的需求。不同的操作系统、硬件架构需要不同的镜像环境来支持它们。Docker 作为一个广泛应用的容器化技术,必然需要能够支持构建跨平台镜像,然而使用 docker manifest 会出现一些奇怪的问题,虽说是官方的测试版本,但是或多或少会遇到一些问题。本文参考github大神的开源代码,来实现构建跨平台镜像。

部署环境

涉及代码

环境依赖

编译代码

git clone https://github.com/estesp/manifest-tool
cd manifest-tool && make binary

编译多架构镜像

示例

编译amd64版本镜像

在x86机器生成的镜像均为amd64的镜像

示例输出镜像为:ubuntu:2004-amd64

编译arm64镜像

在aarch64 aarchv8机器生成的镜像均为amd64的镜像

示例输出镜像为:ubuntu:2004-arm64

使用 manifest-tool 合并多平台镜像

新建test.yaml 文件

image: ubuntu:2004
manifests:
  -
    image: ubuntu:2004-amd64
    platform:
      architecture: amd64
      os: linux
  -
    image: ubuntu:2004-arm64
    platform:
      architecture: arm64
      os: linux

执行镜像推送

# 需要先登陆自己的镜像仓库
docker login
<enter your credentials>

# 执行完推送之后
docker push ubuntu:2004-amd64
docker push ubuntu:2004-arm64

# 合并多平台镜像
./manifest-tool push from-spec test.yaml

# 最终多平台镜像名称为ubuntu:2004

若文章对你有帮助,可以点赞或打赏支持我们。发布者:Aurora,转载请注明出处:http://61.174.243.28:13541/AY-knowledg-hub/%e4%bb%8e0%e5%88%b01%e6%9e%84%e5%bb%ba%e5%a4%9a%e6%9e%b6%e6%9e%84%e9%95%9c%e5%83%8f/

(0)
AuroraAurora站点维系者
上一篇 2023年 12月 15日 上午11:29
下一篇 2023年 4月 21日

相关推荐

发表回复

登录后才能评论
Translate »