How can I delete all local Docker images?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The Builders
--
Chapters
00:00 How Can I Delete All Local Docker Images?
00:34 Accepted Answer Score 2242
01:03 Answer 2 Score 679
01:25 Answer 3 Score 58
01:56 Answer 4 Score 21
02:22 Thank you
--
Full question
https://stackoverflow.com/questions/4478...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #docker #dockercompose
#avk47
ACCEPTED ANSWER
Score 2242
Unix
To delete all containers including its volumes use,
docker rm -vf $(docker ps -aq)
To delete all the images,
docker rmi -f $(docker images -aq)
Remember, you should remove all the containers before removing all the images from which those containers were created.
Windows - Powershell
docker images -a -q | % { docker image rm $_ -f }
Windows - cmd.exe
for /F %i in ('docker images -a -q') do docker rmi -f %i
ANSWER 2
Score 679
Use this to delete everything:
docker system prune -a --volumes
Remove all unused containers, volumes, networks and images
WARNING! This will remove:
    - all stopped containers
    - all networks not used by at least one container
    - all volumes not used by at least one container
    - all images without at least one container associated to them
    - all build cache
https://docs.docker.com/engine/reference/commandline/system_prune/#extended-description
ANSWER 3
Score 58
docker image prune -a
Remove all unused images, not just dangling ones. Add
-foption to force.
Local docker version: 17.09.0-ce, Git commit: afdb6d4, OS/Arch: darwin/amd64
$ docker image prune -h
Flag shorthand -h has been deprecated, please use --help
Usage:  docker image prune [OPTIONS]
Remove unused images
Options:
  -a, --all             Remove all unused images, not just dangling ones
      --filter filter   Provide filter values (e.g. 'until=<timestamp>')
  -f, --force           Do not prompt for confirmation
      --help            Print usage
ANSWER 4
Score 21
Easy and handy commands
To delete all images
docker rmi $(docker images -a)
To delete containers which are in exited state
docker rm $(docker ps -a -f status=exited -q)
To delete containers which are in created state
docker rm $(docker ps -a -f status=created -q)
NOTE: Remove all the containers then remove the images