本文介绍了在Windows上一次停止所有Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何停止Windows上运行的所有Docker容器?
How can I stop all docker containers running on Windows?
docker stop 仅适用于1个容器。
docker stop is for 1 container only.
是否有任何命令/脚本使其停止所有容器?
Any command/script to make it stop all containers?
推荐答案您可以使用以下命令创建批处理文件( .bat 或 .cmd ):
You could create a batch-file (.bat or .cmd) with these commands in it:
@ECHO OFF FOR /f "tokens=*" %%i IN ('docker ps -q') DO docker stop %%i如果要直接在控制台中运行此命令,请替换 %% i 与%i ,例如:
If you want to run this command directly in the console, replace %%i with %i, like:
FOR /f "tokens=*" %i IN ('docker ps -q') DO docker stop %i在 Git Bash 或 Windows版Bash 中,您可以使用以下Linux命令:
In Git Bash or Bash for Windows you can use this Linux command:
docker stop $(docker ps -q)对于 PowerShell ,该命令与Linux命令非常相似:
For PowerShell, the command is very similar to the Linux one:
docker ps -q | % { docker stop $_ }更多推荐
在Windows上一次停止所有Docker容器
发布评论