skopeo镜像工具学习

前言


如果有两个镜像仓库,如何同步镜像到另一个仓库中。

docker buildx –output

–output 可以配置docker buildx 构建结果输出方式。而在本案例中针对双架构的离线文件则使用 oci 格式存储的,所以示例命令如下:

1
docker buildx build --provenance=false --platform=linux/arm64,linux/amd64 -t xxx.com/service/servera:0.0.1 --output type=oci,dest=xxxx.tar .

命令执行完后,当前目录会生成一个xxxx.tar 文件。

安装 skopeo,导入双架构镜像

1.在B CentOS Docker所在的机器中,安装 skopeo 工具。

1
yum install skopeo

2.将离线镜像文件解压到 oci-image 目录(文件夹名字随意定)

1
tar -xf xxxx.tar -C oci-image/

3.使用 copy 命令,导入镜像
使用 copy 命令时,需添加 --all参数,它将 amd64,arm64 全部导出,--dest-tls-verify=false参数作用是在推送到B Docker 私服时,使用 http 协议(在不支持 https 协议时使用)

1
skopeo copy --all --dest-tls-verify=false oci:/xxxxx/oci-image docker://xxx.com/service/servera:0.0.1

注意: 在skopeo copy –all 推送时,若B Docker 私服包含 auth校验,还需提前执行 docker login。

以上操作就完成了 离线镜像文件导入到其他镜像仓库的步骤。

Licensed under CC BY-NC-SA 4.0
最后更新于 Apr 11, 2025 07:19 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up