Docker: How to delete all local Docker images

后端 未结 16 2181
梦谈多话
梦谈多话 2021-01-29 17:24

I recently started using Docker and never realized that I should use docker-compose down instead of ctrl-c or docker-compose stop to get r

相关标签:
16条回答
  • 2021-01-29 17:28

    Adding to techtabu's accepted answer, If you're using docker on windows, you can use the following command

    for /F "delims=" %A in ('docker ps -a -q') do docker rm %A

    here, the command docker ps -a -q lists all the images and this list is passed to docker rm one by one

    see this for more details on how this type of command format works in windows cmd.

    0 讨论(0)
  • 2021-01-29 17:31

    To delete all images:

    docker rmi -f $(docker images -a | awk {'print $3'})
    

    Explanation:

    docker images -a | awk {'print $3'}

    This command will return all image id's and then used to delete image using its id.

    0 讨论(0)
  • 2021-01-29 17:33

    Use this to delete everything:

    docker system prune -a --volumes
    

    Remove all unused containers, volumes, networks and images

    WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all volumes not used by at least one container
        - all images without at least one container associated to them
        - all build cache
    

    https://docs.docker.com/engine/reference/commandline/system_prune/#extended-description

    0 讨论(0)
  • 2021-01-29 17:34

    You can try like this:

    docker system prune
    
    0 讨论(0)
  • 2021-01-29 17:35
    docker rmi $(docker images -q) --force
    
    0 讨论(0)
  • 2021-01-29 17:36

    Delete without invoking docker:

    rm -rf /var/lib/docker
    

    This directly removes all docker images/containers/volumes from the filesystem.

    0 讨论(0)
提交回复
热议问题