Skip to content

Instantly share code, notes, and snippets.

@ichaida
Last active April 2, 2017 18:11
Show Gist options
  • Save ichaida/c84b79b18e13603edf067d267bd98594 to your computer and use it in GitHub Desktop.
Save ichaida/c84b79b18e13603edf067d267bd98594 to your computer and use it in GitHub Desktop.

Docker images/containers cleaning

1- Delete all containers

docker ps -q -a | xargs docker rm

-q prints only the container IDs -a prints all containers

Use xargs to issue a remove container command for each container ID

2- Delete all untagged images

docker rmi -f $(docker images | grep "^<none>" | awk '{print $3}')

Awk must use a single quote otherwise does not recognize the space seperators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment