proxy.ttl not work

Author: balabalabuttonCreated May 15, 2024Updated Sep 21, 2026

Description

deploy a distribution as pull through cache,set proxy.ttl to 1h ,but not work. Initially, proxy.ttl was set to 48h. After caching some images, the container was deleted and the proxy.ttl was modified to 1h and then a new container was created (the data directory is always mounted on the host). But after waiting for several hours, the expected automatic cache clearing did not occur. Checking scheduler-state.json found that all cache images, whether cached when starting the service for the first time or cached for the second time, were set to 7 days. Expiration. The configuration is as follows:

yaml
version: 0.1
log:
  level: debug
  fields:
    service: registry
    environment: development
storage:
  filesystem:
    rootdirectory: /opt/registry/registry-data
  delete:
    enabled: true   
  cache:
    blobdescriptor: inmemory
    blobdescriptorsize: 10000
  maintenance:
    uploadpurging:
      enabled: true
      age: 168h
      interval: 24h
      dryrun: false 
    readonly:
      enabled: false   
proxy:
  remoteurl: https://xxxxx
  username: xxxx
  password: xxxx
  ttl: 48h 
http:
  addr: :5000
  secret: ccr.ccs.tencentyun.com
  debug:
    addr: :5001
    prometheus:
        enabled: true
        path: /metrics 
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3   
auth:
  htpasswd:
    realm: basic-realm
    path: /opt/registry/auth/htpasswd
json
"proxmox/image@sha256:13808c22b207b066ef43572e57e4fb8c6172e887dd9a918c089a174a19371b7a": {
		"Key": "proxmox/image@sha256:13808c22b207b066ef43572e57e4fb8c6172e887dd9a918c089a174a19371b7a",
		"ExpiryData": "2024-05-21T11:59:03.590031813Z",
		"EntryType": 0
	},

Reproduce

docker run -itd -p 5000:5000 -p 5001:5001 --name mharbor -v /opt/registry/registry-data:/opt/registry/registry-data -v /opt/registry/auth:/opt/registry/auth -v /opt/registry/config/config.yml:/etc/docker/registry/config.yml registry:2

Expected behavior

The cache image release time should be 1h, not 7 days

registry version

/ # registry -v registry github.com/docker/distribution 2.8.3

Additional Info

If the ttl takes effect, the first configuration is 48h, and the second time it is changed to 1h to restart the service, then will the first batch of cached images maintain the 48h expiration time, or will they be recalculated with the new ttl to see if they are currently expired or expire after 1h?

Source: distribution/distribution