docker registry batch delete images

Reference addressregistry delete
registry version 2.0 1.Add REGISTRY_STORAGE_DELETE_ENABLED=true to the environment variable when the registry starts



docker run --name registry -e REGISTRY_DELTET_ENABLED=true -e REGISTRY_STORAGE_DELETE_ENABLED=true -e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry -d -p 5000:5000 -v /data/registry/data:/var/lib/registry registry


2. Download the attached registry.py.zip and unzip it

3. Execute the script
python registry.py -l user:pass -r https://registry:5000 --delete
docker exec -it <registry container id or name> registry garbage-collect /etc/docker/registry/config.yml


4. Description
The above script retains the latest 10 versions for each image by default, and the number of retained versions can be set by parameter

python registry.py -l user:pass -r https://registry:5000 --delete --num 3

5. In the process of use, it is found that if the registry is paging, the effect of directly using the registry.py is only to delete the image of the first page. If this happens, you can change the 123 lines of registry.py from result = self.send( '/v2/_catalog') is changed to result = self.send('/v2/_catalog?n=5000'), of which 5000 is only an approximate number, as long as it is more than the total number of mirrors you use

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326217206&siteId=291194637