prune

$ docker system prune --all
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N] y

# prune volume only
$ docker system prune --volumes

docker rmi

  • remove via docker image

    $ docker rmi -f $(docker images "*/*/*/myimage" --format "{{.ID}}")
    
  • or

    $ docker images "*/*/*/myimage" --format "{{.ID}}" | xargs docker rmi -f
    
  • remove <none> tag images

    $ docker images -q -f "dangling=true" | xargs docker rmi -f --no-trunc
    
  • or

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

    $ docker image prune --filter="dangling=true"
    

docker rmi for keywords

$ name='jenkins'
$ tag='2.361.3-lts'
$ if docker images ${name}:${tag} --format \"{{.Tag}}\" >/dev/null ; then
    for imageId in $(docker images ${name} --format \"{{.Tag}}\\t{{.ID}}\" |
                            grep --color=none --fixed-strings ${tag} |
                            awk '{print \$NF}' |
                            uniq);
    do
      docker rmi ${name}:${tag} ;
      docker rmi -f ${imageId} ;
    done ;
  fi
  • cleanup all image path with my.artifactory.com/docker/marslo/
    $ docker rmi -f $(docker images my.artifactory.com/docker/marslo/* -q)
    
    • or
      $ docker rmi -f $(docker images my.artifactory.com/docker/*/* -q)
      

docker rm

  • remove all stopped container

    $ docker ps --filter "status=exited" --format '{{.ID}}' | xargs docker rm -f
    
    • or
      $ docker rm $(docker ps -aq --filter "status=exited")
      
Copyright © marslo 2020-2023 all right reserved,powered by GitbookLast Modified: 2024-03-12 15:01:30

results matching ""

    No results matching ""