更新时间:2022-11-05 15:22:42
对于Unix
要删除所有容器,包括其使用的卷,
To delete all containers including its volumes use,
docker rm -vf $(docker ps -a -q)
要删除所有图像,
docker rmi -f $(docker images -a -q)
请记住,您应该先删除所有容器,然后再删除所有用于创建这些容器的图像.
Remember, you should remove all the containers before removing all the images from which those containers were created.
对于Windows
如果您使用的是Windows(Powershell),
In case you are working on Windows (Powershell),
$images = docker images -a -q
foreach ($image in $images) { docker image rm $image -f }
基于CodeSix的评论,Windows Powershell的一种衬里,
Based on the comment from CodeSix, one liner for Windows Powershell,
docker images -a -q | % { docker image rm $_ -f }
对于使用命令行的Windows,
For Windows using command line,
for /F %i in ('docker images -a -q') do docker rmi -f %i