使用buildx创建多架构镜像

参考文档1:https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images

参考文档2:https://docs.docker.com/desktop/multi-arch/

需求

  • 内核版本 >= 4.8

步骤

1. 启用 binfmt_misc

1
docker run --privileged --rm tonistiigi/binfmt --install all

2. 创建并切换构建器

1
2
3
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx inspect --bootstrap

3. 构建镜像

1
docker buildx build --platform linux/amd64,linux/arm64 -t openspug/spug-service --push .