Docker private registry as kubernetes pod - deleted images auto-recreated
It appears that there is a caching issue at least with registry version 2.7.0 that is described here and here.
It is recommended in the above threads to disable cache completely or to restart the container every time.
Because I am using the docker registry as a kubernetes pod, changes to the default registry configuration file, ie. /etc/docker/registry/config.yml
do not have any effect because the kubernetes registry pod yaml takes precedence, meaning the configuration has to be set in the pod yaml as environment variables in the form of REGISTRY_variable
where the underscore represents indentation levels, as explained in the docs.
So the solution is to add
- name: REGISTRY_STORAGE_CACHE_BLOBDESCRIPTOR
value: ""
to the container environment in the pod yaml in order to disable cache completely, otherwise if the registry is run as a docker container we can use the following in the config.yml
:
storage:
cache:
blobdescriptor: ""
The alternative is to restart the pod every time we delete an image with:
kubectl exec <pod_name> -c <container_name> -- reboot
or if it is a docker container
docker restart <registry_container>