This site has been generated and deployed from Github repository tjtharrison/

Tim Harrison

Infrastructure Team Lead

Deleting an image from the Docker Registry

There is no inbuilt method within the docker provided docker registry so follow the below process to delete images from the registry:

Project repository:

Downloading Script:

curl | sudo tee /scripts/ >/dev/null
sudo chmod a+x /scripts/

Setting up the Script:

In order to setup the script, you will need to export the environment variable used within the script to specify the Docker registry directory – Adjust this as appropriate for your registry.

Note: This should be set to one level up from the “registry” directory which contains one directory per-docker image on the server.

export REGISTRY_DATA_DIR=/mnt/docker-registry/data/docker/registry/v2/

Eg my Docker images are stored within


Running the Script:

Before attempting to delete images you should first stop the Docker container to ensure there are no race conditions (Note this from the Documentation for the Project).

sudo docker-compose stop

Once the container is stopped, you can run the
script with the
flag to simply print what images and layers will be deleted before removing the flag and running it for real (If you are satisfied with the output).

/scripts/ --image example-image --dry-run
/scripts/ --image example-image

Once the files have deleted you can start the registry once more:

sudo docker-compose up -d