docker-sync

command module
v0.0.0-...-aca0cee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

docker-sync

同步 Docker 镜像到指定镜像仓库

go run main.go

config.yml配置如下:

[]为可选

# 分别配置拉取和推送,便于在不同网络环境完成工作
pull: true
push: true

sync:
  - src: REPOSITORY[:TAG][@DIGEST]
    dst: REPOSITORY[:TAG]

同步后输出synced.yml结构:

sync:
  - src: REPOSITORY:TAG@DIGEST
    dst: REPOSITORY:TAG@DIGEST

执行过程

Pull Image
$ docker pull hello-world:latest@sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec

sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec: Pulling from library/hello-world
Digest: sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
Status: Image is up to date for hello-world@sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
docker.io/library/hello-world:latest@sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
通过 REPOSITORY:TAG 查看 ImageId
$ docker images --format {{.ID}} hello-world:latest

bf756fb1ae65
为 ImageId 打 Tag,并 Push
$ docker tag bf756fb1ae65 registry.cn-hangzhou.aliyuncs.com/hb-chen/hello-world:v0.0.1
$ docker push registry.cn-hangzhou.aliyuncs.com/hb-chen/hello-world:v0.0.1

The push refers to repository [registry.cn-hangzhou.aliyuncs.com/hb-chen/hello-world]
9c27e219663c: Preparing
9c27e219663c: Layer already exists
v0.0.1: digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 size: 525

Push 后获取 Digest,输出同步后 Image 列表

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL