Docker – Allow Delete From Docker-Registry

Docker logo

Once your start to build and push new, fresh docker images to your private registry. Or even worse, start automating CI/CD pipeline builds that builds and pushes.. You may end up with Docker images you do not want any more, or that you have created by mistake.

Here’s how to remove them when you are running the official docker-registry Docker deployment.

Add the following to your docker-compose yaml or docker env:

REGISTRY_STORAGE_DELETE_ENABLED: "yes"

Example docker-compose.yaml:

services:
  registry:
    restart: always
    image: registry:2
    ports:
      - "5000:5000"
    environment:
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.password
      REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
      REGISTRY_STORAGE_DELETE_ENABLED: "yes"
    volumes:
      - ./auth:/auth
      - ./data:/data

If you use joxit/docker-registry-ui you can add this to it’s configuration:

- DELETE_IMAGES=true

Example docker-compose.yaml

  ui:
    restart: always
    image: joxit/docker-registry-ui:latest
    ports:
      - "5001:5001"
    environment:
      - REGISTRY_TITLE=Private Docker Registry
      - NGINX_PROXY_PASS_URL=http://registry:5000
      - NGINX_LISTEN_PORT=5001
      - SINGLE_REGISTRY=true
      - DELETE_IMAGES=true
      - SHOW_CONTENT_DIGEST=true

Take out the trash 👾

Leave a Reply

Your email address will not be published. Required fields are marked *