book
  • README
  • cheatsheet
    • bash
      • builtin
      • syntactic sugar
      • cmd
      • havefun
    • text-processing
      • awk
      • sed
      • html
      • json
      • regex
      • unicode
    • osx
    • curl
    • tricky
    • widget
    • proxy
    • colors
    • math
    • media
    • ssl
      • keystore
      • verification
      • server
      • client
      • tricky
    • windows
      • powershell
      • choco
      • wsl
      • wt
      • shortcut
      • clsid
      • env
      • shell:folder
  • vim
    • nvim
    • install
    • color
    • plugins
      • usage
      • other plugins
      • deprecated
    • tricky
    • viml
    • windows
    • troubleshooting
  • devops
    • admin tools
    • ssh
    • git
      • config
      • alias
      • submodule
      • eol
      • example
      • gerrit
        • gerrit API
      • github
      • troubleshooting
      • tricky
      • statistics
    • pre-commit
    • release-tools
    • tmux
      • cheatsheet
    • ansible
    • vault
    • artifactory
      • api
      • cli
      • aql
      • nginx cert
    • klocwork
      • kwadmin
      • kwserver
      • api
      • q&a
    • elk
    • mongodb
    • android
    • mobile
  • jenkins
    • config
      • windows
    • appearance
    • troubleshooting
    • jenkinsfile
      • utility
      • parallel
      • build
      • envvar
      • properties
      • trigger
      • node
    • script
      • job
      • build
      • stage
      • agent
      • security & authorization
      • exception
      • monitor
      • tricky
    • api
      • blueocean
    • cli
    • plugins
      • kubernetes
      • docker
      • shared-libs
      • lockable-resource
      • ansicolor
      • badge
      • groovy-postbuild
      • simple-theme
      • customizable-header
      • artifactory
      • jira-steps
      • job-dsl
      • build-timeline
      • crumbIssuer
      • coverage
      • uno-choice
      • tricky
  • virtualization
    • kubernetes
      • init
        • kubespray
        • kubeadm
          • environment
          • crio v1.30.4
          • docker v1.15.3
          • HA
        • addons
        • etcd
      • kubectl
        • pod
        • deploy
        • replicasets
        • namespace
        • secrets
      • node
      • certificates
      • events
      • kubeconfig
      • kubelet
      • troubleshooting
      • cheatsheet
      • auth
      • api
      • tools
        • monitor
        • helm
        • network
        • minikube
    • docker
      • run & exec
      • voume
      • remove
      • show info
      • dockerfile
      • dockerd
      • tricky
      • troubleshooting
      • windows
    • crio
    • podman
  • ai
    • prompt
  • osx
    • apps
      • init
      • brew
    • defaults
    • system
    • network
    • script
    • tricky
  • linux
    • devenv
    • util
      • time & date
      • output formatting
      • params
      • tricky
    • nutshell
    • disk
    • network
    • troubleshooting
    • system
      • apt/yum/snap
      • authorization
      • apps
      • x11
    • ubuntu
      • systemctl
      • x
    • rpi
  • programming
    • groovy
    • python
      • config
      • basic
      • list
      • pip
      • q&a
    • others
    • archive
      • angular
      • maven
      • mysql
        • installation
        • logs
      • ruby
        • rubyInstallationQ&A
  • tools
    • fonts
    • html & css
    • Jira & Confluence
    • node & npm
      • gitbook
      • hexo
      • github.page
      • code themes
    • app
      • microsoft office
      • vscode
      • virtualbox
      • iterm2
      • browser
      • skype
      • teamviewer
      • others
  • quotes
  • english
Powered by GitBook
On this page
  • prune
  • docker rmi
  • docker rm

Was this helpful?

  1. virtualization
  2. docker

remove

PreviousvoumeNextshow info

Last updated 1 year ago

Was this helpful?

$ 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
  • show info

    [!NOTE|label:see also:]

    $ docker system df
$ docker builder prune
WARNING! This will remove all dangling build cache. Are you sure you want to continue? [y/N] y
ID                               RECLAIMABLE SIZE    LAST ACCESSED
inqm9ef8j6121j79yti92w2o5        true        0B      3 weeks ago
...

# or
$ docker builder prune [ --all ] [ --force ] [ --keep-storage ]

prune containers

$ docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
5619dd2ca2fda889dea74a7951715aebabe08c05863eff6a9be0b108394111ec
e777013b304984b0315099f142cc24d942902ac42b62e53ebe1d52a6102912a9
7c09bf8b650968557a975e2cd1f43f6612307af892b5b864ac7b795a59b02d2c
ce2e8698d03f6d6b2a8afcd8655baadc5bb31fbe9eaf425e015e0e4f476e0872
5ee7d62799822a708de6d6b11c2dfbf04114784a77b574da4aa88d63757c180a

Total reclaimed space: 41.47MB

# force
$ docker container prune --force
$ docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
...

# all
$ docker volume prune --all

# force
$ docker volume prune --all --force
$ docker image prune

# all
$ docker image prune --all

# force
$ docker image prune --all --force

docker rmi

  • remove via docker image

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

      $ docker images "*/*/*/myimage" --format "{{.ID}}" | xargs docker rmi -f
  • $ docker images -q -f "dangling=true" | xargs docker rmi -f --no-trunc
  • or

    $ docker rmi -f $(docker images --filter dangling=true -q)
  • $ 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 artifactory.sample.com/docker/marslo/

    $ docker rmi -f $(docker images artifactory.sample.com/docker/marslo/* -q)
    • or

      $ docker rmi -f $(docker images artifactory.sample.com/docker/*/* -q)

docker rm

  • $ docker ps --filter "status=exited" --format '{{.ID}}' | xargs docker rm -f
    • or

      $ docker rm $(docker ps -aq --filter "status=exited")

iMarslo: show info
prune build cache
prune volumes
prune images
remove <none> tag images
or
remove all stopped container
prune
prune
prune build cache
prune containers
prune volumes
prune images
docker rmi
docker rmi for keywords
docker rm