CleanUpDocker: Difference between revisions

From DrewWiki
Jump to navigation Jump to search
(Added CleanUpDocker)
 
(fix syntax for CleanUpDocker)
 
(One intermediate revision by the same user not shown)
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
</syntaxhighlight>
Work around:
<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 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