How can I delete Docker's images?

后端 未结 17 1273
执笔经年
执笔经年 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:10

    The reason for the error is that even though the image did not have any tag, there still exists a container created on that image which might be in the exited state. So you need to ensure that you have stopped and deleted all containers created on those images. The following command helps you in removing all containers that are not running:

    docker rm `docker ps -aq --no-trunc --filter "status=exited"`
    

    Now this removes all the dangling non-intermediate images:

    docker rmi `docker images --filter 'dangling=true' -q --no-trunc`
    

    Note: To stops all running containers:

    docker stop `docker ps -q`
    

提交回复
热议问题