Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Cleaning up:

Docker recently added a docker system prune command which can be used for thorough and convenient cleanup. Environments which don't yet sport the command, however, offer the following alternatives.  

  • Remove unused volumes (do not run on <= 1.9): 

    Code Block
    docker volume rm $(docker volume ls -qf dangling=true)


  • Remove unused images:

    Code Block
    docker images | grep "<none>" | awk '{print $3}' | xargs docker rmi


  • Remove all exited containers:

    Code Block
    docker rm `docker ps -a  | grep Exit | awk '{ print $1 }'`

    or

    Code Block
    docker stop $(docker ps -a -q)
    docker rm $(docker ps -a -q)


  • Attempt to remove all networks:

Code Block
docker network rm $(docker network ls --format “{{.ID}}“)

More Resources

...