Skip to content

How to prune image with filter #843

@anemptyair

Description

@anemptyair

Hi guys:
I want to prune images like the command : docker image prune -a --force --filter "until=30m"
How should I set the filter, my code is below:

                filter := make(map[string][]string, 0)
		util := time.Duration(30) * time.Minute
		filter["until"] = []string{util.String()}
		pruneImages := docker.PruneImagesOptions{Filters: filter}
		pruneResult, err := dockerCli.PruneImages(pruneImages)
		if err != nil {
			logrus.Printf("[Docker cleaner] PruneImages error:%s", err.Error())
			return err
		}

But it doesn't work , please give me a help, thank u.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions