0

I'd like to provide for our disconnected container infrastructure (OKD, Harbor) several base images, which are automatically weekly renewed (re-created) and images older than XX days are pruned.

For that I've adopted a script which creates a centos base image, imports it into the local docker registry (docker import tar file) and pushes it to harbor afterwards.

Now I'd like to add a logic to prune only the images in that specific repository and only images older than XX days.

For that I've tried several variants of the "docker image prune" command and setting filters - for my understanding I could set filters like:

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

#docker images
REPOSITORY                                                    TAG        IMAGE ID       CREATED        SIZE
centos_base                                                   7.9.2009   54ab4ae0746a   10 hours ago   283MB

But the filter with label seems not to work in that way:

# docker image ls --filter "label=centos_base"
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

So I would try now to set labels on the base_images, but that assumes that you use a Dockerfile, which seems a bit to cumbersome for my purposes.

Is there a way to add the labels during import or afterwards, or is there a completely different and more practical way for this?

How do you handle this topic?

mschau
  • 1

0 Answers0