How can I delete Docker's images?

后端 未结 17 1205
执笔经年
执笔经年 2020-11-29 14:27

I\'ve the following images:

alex@alexvps:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
&         


        
17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 15:05

    Simply you can aadd --force at the end of the command. Like:

    sudo docker rmi  --force
    

    To make it more intelligent you can add as:

    sudo docker stop $(docker ps | grep  | awk '{print $1}')
    
    sudo docker rm $(docker ps | grep  | awk '{print $1}')
    
    sudo docker rmi $(docker images | grep  | awk '{print $3}') --force
    

    Here in docker ps $1 is the first column, i.e. the Docker container ID.

    And docker images $3 is the third column, i.e. the Docker image ID.

提交回复
热议问题