Docker Community Forums

Share and learn in the Docker community.

Docker clear cache in windows 10

docker

(Karenwebdev) #1

Hi all. I have tried to clear cache of docker, and have used the following commands
docker kill $(docker ps -q)
docker rmi $(docker images -a -q)

but the response I have got the error look like this
unknown shorthand flag: ‘a’ in -a


(Gdouaire) #2

Why not use docker system prune -a ?


(Sergio Vazquez II) #3

I am having the exact same problem. Does anyone have a solution for this error?
I just want to STOP all containers, NOT remove them.

Thanks!

Docker Desktop on Windows 10
Version 2.0.0.2 (30215)
Channel: stable
Build: 0b030e1


(Gary Forghetti) #4

Try this command from Powershell since you are running Docker for Windows.

docker container stop (docker container ls -q) | Out-String

Example

PS C:\Users\Administrator> docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES
951fe970b796        hello-world         "powershell sleep 10…"   8 seconds ago        Up 6 seconds                            lucid_ishizaka
2438ae721cb4        hello-world         "powershell sleep 10…"   About a minute ago   Up About a minute                       recursing_elbakyan
PS C:\Users\Administrator> docker container stop (docker container ls -q) | Out-String
951fe970b796
2438ae721cb4
PS C:\Users\Administrator> docker container stop (docker container ls -q) | Out-String
951fe970b796
2438ae721cb4
PS C:\Users\Administrator> docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
PS C:\Users\Administrator> docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                              PORTS               NAMES
951fe970b796        hello-world         "powershell sleep 10…"   17 seconds ago       Exited (3221226219) 4 seconds ago                       lucid_ishizaka
2438ae721cb4        hello-world         "powershell sleep 10…"   About a minute ago   Exited (3221226219) 4 seconds ago                       recursing_elbakyan

You can start them back up.

PS C:\Users\Administrator> docker container start 951fe970b796
951fe970b796
PS C:\Users\Administrator> docker container start 2438ae721cb4
2438ae721cb4
PS C:\Users\Administrator> docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
951fe970b796        hello-world         "powershell sleep 10…"   51 seconds ago      Up 13 seconds                           lucid_ishizaka
2438ae721cb4        hello-world         "powershell sleep 10…"   2 minutes ago       Up 2 seconds                            recursing_elbakyan