CleanUpDocker: Difference between revisions

From DrewWiki
Jump to navigation Jump to search
No edit summary
(fix syntax for CleanUpDocker)
 
Line 1: Line 1:
Remove all containers then remove all images
Remove all containers then remove all images
<syntaxhighlight>
<syntaxhighlight lang=bash>
$ docker ps -a | cut -f 1 -d" " | xargs docker rm
$ docker ps -a | cut -f 1 -d" " | xargs docker rm
$ docker images | awk '{print $3}' | xargs docker rmi
$ docker images | awk '{print $3}' | xargs docker rmi
Line 6: Line 6:


Work around:
Work around:
<syntaxhighlight>  
<syntaxhighlight lang=bash>  
docker ps -a -f status=dead -q | xargs -r -I % bash -c 'rm -rf /srv/docker/overlay/%1*'
docker ps -a -f status=dead -q | xargs -r -I % bash -c 'rm -rf /srv/docker/overlay/%1*'
docker ps -a -f status=dead -q | xargs -r docker rm -f -v
docker ps -a -f status=dead -q | xargs -r docker rm -f -v
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 22:58, 24 January 2018

Remove all containers then remove all images

$ docker ps -a | cut -f 1 -d" " | xargs docker rm
$ docker images | awk '{print $3}' | xargs docker rmi

Work around:

 
docker ps -a -f status=dead -q | xargs -r -I % bash -c 'rm -rf /srv/docker/overlay/%1*'
docker ps -a -f status=dead -q | xargs -r docker rm -f -v