Shell脚本:将所有Docker镜像导入私有仓库
#!/bin/bash
DOCKER_REGISTRY='your.docker.registry.com' DOCKER_NAMESPACE='your-namespace' DOCKER_USERNAME='your-username' DOCKER_PASSWORD='your-password'
docker login -u '$DOCKER_USERNAME' -p '$DOCKER_PASSWORD' '$DOCKER_REGISTRY'
获取所有docker镜像的id
images=$(docker images --format '{{.Repository}}:{{.Tag}}')
导入镜像到私有仓库
for image in $images do docker tag $image '$DOCKER_REGISTRY/$DOCKER_NAMESPACE/$image' docker push '$DOCKER_REGISTRY/$DOCKER_NAMESPACE/$image' done
echo 'All images have been imported to your private registry.'
原文地址: https://www.cveoy.top/t/topic/mAHb 著作权归作者所有。请勿转载和采集!