Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prune image with filter #843

Open
anemptyair opened this issue Sep 3, 2020 · 5 comments
Open

How to prune image with filter #843

anemptyair opened this issue Sep 3, 2020 · 5 comments

Comments

@anemptyair
Copy link

anemptyair commented Sep 3, 2020

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.

@fsouza
Copy link
Owner

fsouza commented Sep 4, 2020

Hi @anemptyair, thanks for opening this issue. Do you get any errors?

I'm not entirely familiar with that feature. What does the until filter do? (Just want to figure out how to test this locally).

@anemptyair
Copy link
Author

It is refer : https://docs.docker.com/engine/reference/commandline/image_prune/
The following removes images created more than 10 days (240h) ago:
e.g : docker image prune -a --force --filter "until=240h"

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Oct 4, 2020
@fsouza fsouza removed the stale label Oct 4, 2020
@fsouza fsouza added the nostale label Nov 1, 2020
@pavan541cs
Copy link

@fsouza Can I work on this issue ?

@fsouza
Copy link
Owner

fsouza commented Sep 23, 2021

@pavan541cs go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants