Ir al contenido
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Inicia sesión
  • Nederlands English (US) Español (AR)
  • Contáctanos
  • Inicio
  • Blog
  • Empleos
  • Contáctanos
Cafayate.Net
  • 0
  • 0
    • Inicio
    • Blog
    • Empleos
    • Contáctanos
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Inicia sesión
  • Contáctanos

Docker Cleanup Commands

  • Todos los blogs
  • Tech Blog
  • Docker Cleanup Commands
  • 5 de marzo de 2021 por
    Administrator

     

    I’ve been working quite a bit with Docker these last few weeks and one thing that I found really annoying was all these unused containers and images taking up precious disk space.

    I wish Docker has a ‘docker clean’ command that would delete stopped containers and untagged images. Perhaps sometime in the near future as the project is very active. But for the time being, these commands should do the job.

    Kill all running containers

    docker kill $(docker ps -q)
    

    Delete all stopped containers (including data-only containers)

    docker rm $(docker ps -a -q)
    

    Delete all ‘untagged/dangling’ (<none>) images

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

    Delete ALL images

    docker rmi $(docker images -q)

    It might also be useful to create bash aliases for these commands, for example:

    # ~/.bash_aliases
    
    # Kill all running containers.
    alias dockerkillall='docker kill $(docker ps -q)'
    
    # Delete all stopped containers.
    alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
    
    # Delete all untagged images.
    alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
    
    # Delete all stopped containers and untagged images.
    alias dockerclean='dockercleanc || true && dockercleani'

    Update (9/9/2015):

    Also check out this script if your /var/lib/docker directory seems to be getting unusually big as there may be a bunch of orphaned Docker volumes that can be cleaned up. We ran into this issue recently where developers were starting to ran out of space on their hard drive and turned out we had so many orphaned volumes.

     

    To kill all running containers you should replace “docker ps -aq” with “docker ps -q”, since “-a” option lists all stopped containers too.

     

     

    en Tech Blog
    How to activate Facebook Comments in Odoo

    Diseñado para empresas

    Somos un equipo de personas apasionadas cuyo objetivo es mejorar la vida de todos a través de productos revolucionarios. Creamos grandes productos para resolver sus problemas empresariales. Nuestros productos están diseñados para pequeñas y medianas empresas dispuestas a optimizar su rendimiento.

    Contáctenos

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Síganos
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)