Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: skopeo sync How to preserve the project name of the mirror #1992

Open
jinjianming opened this issue May 4, 2023 · 6 comments
Open
Labels
kind/feature A request for, or a PR adding, new functionality stale-issue

Comments

@jinjianming
Copy link

For example mine : sync.yml

 registry.js.design:
      images:
          justwatch/elasticsearch_exporter:
              - "1.1.0"
          elasticsearch/elasticsearch:
              - "7.8.1"

My Sync Command

skopeo sync --tls-verify=false --src yaml --dest docker sync.yml js-registry:5000/

My expected effect

js-registry:5000/justwatch/elasticsearch_exporter:1.1.0
js-registry:5000/elasticsearch/elasticsearch:7.8.1

Actual effect

js-registry:5000/elasticsearch_exporter:1.1.0
js-registry:5000/elasticsearch:7.8.1
@jinjianming jinjianming changed the title help: skopeo sync How to keep mirroring to project names help: skopeo sync How to preserve the project name of the mirror May 4, 2023
@mtrmac
Copy link
Contributor

mtrmac commented May 4, 2023

There is --scoped, but that might also not do exactly what you need.

@jinjianming
Copy link
Author

--scoped,但这也可能无法完全满足您的需要。

I tried it and brought over the domain name of the source warehouse. I only want to bring the following path

[root@js-staging-env-177 ~]# skopeo sync  --scoped --src docker --dest docker --src-tls-verify=false --dest-tls-verify=false registry.js.design/bitnami/redis-exporter:1.24.0-debian-10-r9 js-registry:5000/
INFO[0000] Tag presence check                            imagename="registry.js.design/bitnami/redis-exporter:1.24.0-debian-10-r9" tagged=true
INFO[0000] Copying image ref 1/1                         from="docker://registry.js.design/bitnami/redis-exporter:1.24.0-debian-10-r9" to="docker://js-registry:5000/registry.js.design/bitnami/redis-exporter:1.24.0-debian-10-r9"

reality

js-registry:5000/registry.js.design/bitnami/redis-exporter:1.24.0-debian-10-r9

expect

js-registry:5000/bitnami/redis-exporter:1.24.0-debian-10-r9

@mtrmac
Copy link
Contributor

mtrmac commented May 5, 2023

Yes; I think the only way right now is to split up the YAML file and run skopeo sync several times with different destinations.

@jinjianming
Copy link
Author

是的; 我认为现在唯一的方法是拆分 YAML 文件并skopeo sync在不同的目的地运行多次。

I implemented it through the following script

function sync_docker(){
    REGISTRY="js-registry:5000"
    local yml_file=$2
# Get image names and tags from sync.yml and iterate through them
 cat $yml_file  | yq -o=json .[].images | jq -r 'to_entries[] | "\(.key):\(.value[0])"' | while read line; do
    image=$(echo "$line" | cut -d',' -f2)   # Extract image name and tag
    project=$(echo "$line" | cut -d',' -f1 | cut -d'/' -f1 )   # Extract project name
    dest_image="${REGISTRY}/${project}"   # Construct destination image name

    # Use skopeo sync to copy image from source to destination
    skopeo --insecure-policy sync \
        --src docker \
        --dest docker \
        --src-tls-verify=false \
        --dest-tls-verify=false \
        "registry.js.design/${image}" "${dest_image}"
done
}

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

A friendly reminder that this issue had no activity for 30 days.

@mtrmac mtrmac added the kind/feature A request for, or a PR adding, new functionality label Jun 30, 2023
@github-actions
Copy link

github-actions bot commented Aug 1, 2023

A friendly reminder that this issue had no activity for 30 days.

TechIsCool added a commit to TechIsCool/skopeo that referenced this issue May 15, 2024
  - Add `RegistryName` field to `repoDescriptor` for better registry handling.
  - Introduce `getSubPath` function to cleanly handle subpath extraction.
  - Update functions `imagesToCopyFromRegistry` and `filterSourceReferences` to include `RegistryName`.
  - Modify `syncOptions.run` to use `getSubPath`.
  - Add unit tests for `getSubPath`.

Resolves
  - containers#1992
TechIsCool added a commit to TechIsCool/skopeo that referenced this issue May 15, 2024
  - Add `RegistryName` field to `repoDescriptor` for better registry handling.
  - Introduce `getSubPath` function to cleanly handle subpath extraction.
  - Update functions `imagesToCopyFromRegistry` and `filterSourceReferences` to include `RegistryName`.
  - Modify `syncOptions.run` to use `getSubPath`.
  - Add unit tests for `getSubPath`.

Resolves
  - containers#1992

Signed-off-by: David Beck <techiscool@gmail.com>
TechIsCool added a commit to TechIsCool/skopeo that referenced this issue May 15, 2024
  - Add `RegistryName` field to `repoDescriptor` for better registry handling.
  - Introduce `getSubPath` function to cleanly handle subpath extraction.
  - Update functions `imagesToCopyFromRegistry` and `filterSourceReferences` to include `RegistryName`.
  - Modify `syncOptions.run` to use `getSubPath`.
  - Add unit tests for `getSubPath`.

Resolves
  - containers#1992

Signed-off-by: David Beck <techiscool@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for, or a PR adding, new functionality stale-issue
Projects
None yet
Development

No branches or pull requests

2 participants