- Update all images with local download tag
# 1. list images
# 2. split with the space, and filter out the first line, and the 2nd element is not "none", and finally combine the 1st and 2nd element
# 3. update the docker images and prune finally
docker image ls | \
awk '(NR>1) && ($2!~/none/) {print $1":"$2}' | \
xargs -L1 docker image pull; docker image prune -f
- make all images not starting with
harbor.test.com
create a new tag with the startsharbor.test.com/3rd
docker image ls | \
awk '(NR>1) && ($2!~/none/) && ($1!~/^harbor.test.com/) {print $1":"$2}' | \
xargs -I @ docker image tag @ harbor.test.com/3rd/@
- push all images
docker image ls | \
awk '(NR>1) && ($2!~/none/) && ($1~/^harbor.test.com/) {print $1":"$2}' | \
xargs -L1 docker image push
awk:
NR>1
: NR means Number of Record; NR>1 means only rows above 2 are processed (skipping the first row)$2!~/none/
: the 2nd element should not be "none"$1!~/^harbor.test.com/
: the 1st element should not start with "harbor.test.com"
xargs:
-I @
: let the args in the middle
Update images without the prefix
harbor.test.com