本文作者:丁辉
DockerHub上传双架构镜像
Docker manifest 推送双架构镜像
构建并推送镜像
X85执行
1
2docker build -t offends/demo-x86:v1 .
docker push offends/demo-x86:v1arm执行
1
2docker build -t offends/demo-arm:v1 .
docker push offends/demo-arm:v1
创建 manifest
1
2
3docker manifest create offends/demo:v1 \
offends/demo-x86:v1 \
offends/demo-arm:v1为镜像指定架构
1
2
3
4
5
6
7docker manifest annotate offends/demo-x86:v1 \
offends/demo-x86:v1 \
--os linux --arch x86_64
docker manifest annotate offends/demo-arm:v1 \
offends/demo-arm:v1 \
--os linux --arch arm64 --variant v8查看
1
docker manifest inspect offends/demo:v1
推送
1
docker manifest push offends/demo:v1
Docker Buildx 推送双架构镜像
安装 Buildx
1
2
3
4mkdir -p ~/.docker/cli-plugins
mv buildx-v*.linux-amd64 ~/.docker/cli-plugins/docker-buildx
chmod +x ~/.docker/cli-plugins/docker-buildx
docker buildx version添加模拟仓库
1
docker run --privileged --rm tonistiigi/binfmt --install all
内核版本需要升级,如果过低无法添加成功
查看
1
2
3
4
5docker buildx ls
#一下是输出
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
default * docker
default default running v0.8+unknown linux/amd64, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/arm/v7, linux/arm/v6创建 builder 示例
1
docker buildx create --name dmeo --use
构建混合建构镜像
1
docker buildx build --platform linux/amd64,linux/arm64/v8 -t demo:v1 --push .
Docker Buildx使用私有仓库 推送双架构镜像
部署私有镜像仓库
启动镜像仓库
1
2
3
4
5
6docker run -d \
--name docker-registry \
--restart=always \
-p 5000:5000 \
-v /root/private-registry:/var/lib/registry \
registry将本机Docker添加非安全仓库
Buildx 只允许 https 协议的镜像仓库使用,这里的方法之建议测试使用
1
2
3
4
5
6cat > /etc/docker/daemon.json <<EOF
{
"experimental": true,
"insecure-registries": ["192.168.1.10:5000"]
}
EOF重启 docker 进程启用
1
systemctl restart docker
将 buildkit 镜像推送到私仓
1
2docker tag moby/buildkit:buildx-stable-1 192.168.1.10:5000/buildkit:buildx-stable-1
docker push 192.168.1.10:5000/buildkit:buildx-stable-1新增 buildkit 私仓配置
1
2
3
4
5
6cat > /etc/buildkit/buildkitd.toml << EOF
debug = true
[registry."192.168.1.10:5000"]
http = true
insecure = true
EOF创建 builder
1
2
3
4docker buildx create --use \
--name builder \
--driver-opt image=192.168.1.10:5000/buildkit:buildx-stable-1 \
--config /etc/buildkit/buildkitd.toml构建混合建构镜像
1
docker buildx build --platform linux/amd64,linux/arm64/v8 -t 192.168.1.10:5000/demo:v1 --push .
查看
1
curl http://192.168.1.10:5000/v2/_catalog
清理
删除构建器实例
1 | docker buildx rm builder |
I'm so cute. Please give me money.
- 本文链接: https://blog.offends.cn/Kubernetes/Docker/Docs/DockerHub上传双架构镜像.html
- 版权声明: 本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。