I recently started using Docker and never realized that I should use docker-compose down
instead of ctrl-c
or docker-compose stop
to get r
Adding to techtabu's accepted answer, If you're using docker on windows, you can use the following command
for /F "delims=" %A in ('docker ps -a -q') do docker rm %A
here, the command docker ps -a -q
lists all the images and this list is passed to docker rm
one by one
see this for more details on how this type of command format works in windows cmd.
To delete all images:
docker rmi -f $(docker images -a | awk {'print $3'})
Explanation:
docker images -a | awk {'print $3'}
This command will return all image id's and then used to delete image using its id.
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
You can try like this:
docker system prune
docker rmi $(docker images -q) --force
Delete without invoking docker:
rm -rf /var/lib/docker
This directly removes all docker images/containers/volumes from the filesystem.