dockernexusdocker-imageharbor

Script to push and pull all images from nexus to harbor


i want to pull from nexus all images and push them in harbor i try to do that

but the problem is that i have a lot of images and if i do this operation i need to write 1 line for every images so i want something like a loop too pull and push all images from nexus any help ?!


Solution

  • You can try use bash script, for example

    #!/bin/bash
    docker login -u -p https://harbor.domaine.com/
    for image_name in $(docker images --format="{{.Repository}}:{{.Tag}}" | grep nexus.domaine.com)
    do
      new_image_name=$(echo $image_name | sed 's/nexus.domaine.com/harbor.domaine.com\/project_name/')
      docker tag $image_name $new_image_name
      docker push $new_image_name
    done