question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I use Prune so that it gets all of the images?

See original GitHub issue

I built an image and then afterward ran client.images.prune(). The returned dict stated {'ImagesDeleted': None, 'SpaceReclaimed': 0}. I then ran docker system prune -a -f and saw that it deleted a lot of space (~1gb). I then tried client.images.remove, but that also did nothing.

What’s the correct way of pruning the system from docker-py?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

5reactions
shin-commented, May 25, 2018

The -a option in the CLI is equivalent to setting the dangling filter to false. (according to https://github.com/docker/cli/blob/master/cli/command/image/prune.go#L59)

In short, docker image prune -a -f translates as such: client.images.prune(filters={'dangling': False})

1reaction
rodrigodlimacommented, Apr 30, 2018

For me, the client.images.prune() don’t works too. For example, I have one image nginx:1.12.2 that is not in use for any container, when I run the client.images.prune(), this image is not removed.

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
>>> client = docker.from_env()
>>> client.images.list()
[<Image: 'docker.io/nginx:1.12.2'>, <Image: 'docker.io/nginx:latest'>, <Image: 'docker.io/alpine:latest'>]
>>> client.images.prune()
{u'SpaceReclaimed': 0, u'ImagesDeleted': None}

[root@localhost ~]# docker image prune -a -f Deleted Images: untagged: docker.io/nginx:1.12.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

docker image prune - Docker Documentation
docker image prune -a WARNING! This will remove all images without at least one container associated to them. Are you sure you want...
Read more >
How To Remove All Stopped Containers And Unused Images ...
In this video, I will explain the prune command which will help to remove containers and images.docker container prunedocker system prune ...
Read more >
Docker prune explained - usage and examples
Docker prune is the way to clean up containers, images, volumes and networks on your system. See how to remove unused resources, ...
Read more >
How to Prune Docker Images Automatically with a Daily Cron ...
Docker has a fantastic 'prune' command to tell it to cleanup all unused docker containers but unfortunately this is not something that it...
Read more >
How To Remove Docker Images, Containers, and Volumes
Note: The command substitution syntax, command $( command ) , used in the commands is available in many popular shells, such as bash,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found