Thor Samsberg
Thor Samsberg

Reputation: 2279

Docker ate up all my disk space

I played with docker all day and finally I ran out of disk space.

docker ps
docker images
docker volume ls

All this commands show me nothing (I delete all images, containers and volumes). But there is still no space at all.

Did missed something ? (I am sure docker is guilty for this=), at the morning there was 100 GB free space) p.s. I am on OSx

Update

I freed the space by deleting docker-machine

docker-machine rm default

I believe, it is not a brilliant solution, what would I do if it was linux environment ? =) So any suggestion by keeping docker away from eating disk space would be great.

Upvotes: -1

Views: 3152

Answers (4)

WiringHarness
WiringHarness

Reputation: 381

docker system prune gets rid of all Docker components that are dangling, such as images or networks that are not named and not part of a running container.

Upvotes: 1

vishal sahasrabuddhe
vishal sahasrabuddhe

Reputation: 768

Docker use /var/lib/docker folder to store the layers. There are ways to reclaim the space and move the storage to some other directory.

You can mount a bigger disk space and move the content of /var/lib/docker to the new mount location and make sym link.

There is detail explanation on how to do above task.

http://www.scmtechblog.net/2016/06/clean-up-docker-images-from-local-to.html

You can remove the intermediate layers too.

https://github.com/vishalvsh1/docker-image-cleanup

##Removing Dangling images
##There are the layers images which are being created during building docker image. This is a great way to recover the spaces used by old and unused layers.

docker rmi $(docker images -f "dangling=true" -q)

##If you do not want to remove all container you can have filter for days and weeks old like below
docker ps -a | grep Exited | grep "days ago" | awk '{print $1}' | xargs docker rm
docker ps -a | grep Exited | grep "weeks ago" | awk '{print $1}' | xargs docker rm

##Removing stopped container
docker ps -a | grep Exited | awk '{print $1}' | xargs docker rm

Upvotes: 0

devesh-ahuja
devesh-ahuja

Reputation: 1052

If you're sure, that it has happened because of docker, then you can try below commands:

On Linux:

service docker stop
rm -rf /var/lib/docker ( the default graphdriver which you have set)
service docker start

NOTE: It would remove all your images and containers.

On Mac:

docker-machine ls
docker-machine kill <machine-name> #to kill machine 
docker-machine rm <machine-name>   #to remove machine

Upvotes: 4

irakli
irakli

Reputation: 869

Delete all the images that are not used by any active containers (stopped containers are still active!):

docker images | grep -i none | awk '{print $3}' | xargs docker rmi -f

Delete all docker images (not necessarily recommended but clearly better than deleting the host, which is what your docker-machine thing did :)):

docker images | awk '{print $3}' | xargs docker rmi -f

Upvotes: 4

Related Questions