redhat-cop / openshift-toolkit

A collection of code samples to help you get started with OpenShift
Apache License 2.0
232 stars 150 forks source link

docker-registry-sync.py fills local /var partition when pushing to private registry #128

Open davewujcik opened 4 years ago

davewujcik commented 4 years ago

Hi, I'm trying to use your docker-registry-sync.py script to populate a disconnected registry for an OCP 3.11 install at a customer site.

I noticed that the script caches the images locally on the server running the script and is storing the images in /var/lib/docker/overlay2

We don't have enough storage on the box running the script to handle this and it would be real convenient if the script had an option to delete each local image after it pushes to the remote registry.

The script also doesn't seem to have any functionality to clean up after itself at the end of the run. This will lead to eventual filling of any partition as the registry images come out with newer versions/etc. All the old versions will remain on the filesystem until manually deleted via "docker image rm..."

Thanks,

-- Dave Wujcik (dwujcik) at (red hat)

davewujcik commented 4 years ago

For my purposes, I modified dry_run_print_docker_commands() to include the below two lines at the end:

print("docker image rm %s/%s" % (local_registry, image_name)) print("docker image rm %s/%s" % (remote_registry, image_name))

I then used the --dry-run option to print out all the docker commands including the newly added image removal. This way I could run them in chunks, and stop/resume easily at certain points (we have a low-bandwidth link to the internet).