Providing Docker Base Images

Viewed 27

I'm trying to automatically provide weekly created base images for e.g. centos, coreos, etc. in our disconnected infrastructure which comprises okd and a harbor registry.

For that I use a script link which downloads centos core packages and imports it into a local docker registry with "centos_base" repository name and a tag of the current centos version (eg. centos_base:7.9.2009). I've added a few lines to the script in order to push the image to an according harbor project and repo.

Now I'd like to add some further logic to clean up older images (> 180d) only from specific repos and tried some commands like

docker image prune --filter "until=$(date +'%Y-%m-%dT%H:%M:%S' --date='-180 days')" --filter "reference='centos_base:*'"

Error response from daemon: Invalid filter 'reference'

which does not work, because of inconsistencies in filter options for different docker commands...

How did you solve this topic?

Glad for any hints on this!

1 Answers

In the Documentation it states that the docker image prune command only supports:

  • until (<timestamp>) - only remove images created before given timestamp
  • label (label=<key>, label=<key>=<value>, label!=<key>, or label!=<key>=<value>) - only remove images with (or without, in case label!=... is used) the specified labels.

https://docs.docker.com/engine/reference/commandline/image_prune/#filtering

So you may want to try the parameter

--filter "label=Repository=centos_base"
Related