Reputation: 993
I'm using docker for Windows to launch a MSSQL server. Everything is working fine except for the fact that my harddrive is now full. I've used all the cleanup commands that docker has, removing all images and containers:
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -f dangling=true)
docker rmi $(docker images -q)
This will not remove any contents in the c:\ProgramData\Docker\windowsfilter folder, where there are still a lot of file. Roughly 130gb worth's of storage, without any running containers or stored images.
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: windows/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.24)
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: windows/amd64
Experimental: true
I tried to use the docker-ci-zap (https://github.com/jhowardmsft/docker-ci-zap) , but running that tool is not recommended so I would rather use an alternative solution
Upvotes: 48
Views: 68251
Reputation: 582
I had a similar issue after running windows containers. My windowsfilter
folder size increased to ~80GB and I couldn't delete those files manually or with docker system prune --volumes
. After googling for so many hours, I always ended with the docker-ci-zap.exe
solution which is not recomended. Then, I figured out a easy workaround by reading https://github.com/docker/for-win/issues/745#issuecomment-444461889.
The workaround is adding -removing
suffix to the folders you wish to delete within windowsfilter
directory and restarting the docker. This triggers docker to cleanup the folders properly at startup. I have experienced docker cleaning at most 10 folders in every startup. If you have more then 10 folders, then you might restart several time to remove all of them.
You can use the following command if you want to get rid of all the files.
Get-ChildItem -Path D:\docker\data\windowsfilter -Directory | % {Rename-Item $_.FullName "$($_.FullName)-removing" -ErrorAction:SilentlyContinue}
Upvotes: 7
Reputation: 12386
Had about ~40GB for ext4.vhdx file and ~17gb for ProgramData/Docker Desktop. If you are using Docker Desktop it easy to clean it :
Just open it, click Troubleshoot and then Clean/Purge data
Works fine for me.
Upvotes: 21
Reputation: 3057
Solution update for 2021
NOTE:
All command executed in ADMIN powershell
First step: Clean all the images and the volumes.
docker image ls # These images will be all deleted
docker image prune -a -f
docker volume ls # These volumes will be all deleted
docker volume prune -a -f
docker system prune -a -f
Second step: Stop docker service
Right click on the docker icon or taskkill /F /IM "Docker Desktop.exe"
. Then: net stop com.docker.service
Third step: Reduce the .vhdx
file size
Optimize-VHD -Path "C:\Users\alessiosavi\AppData\Local\Docker\wsl\data\ext4.vhdx" -Mode Full
Now you can restart the docker service: net start com.docker.service
Upvotes: 1
Reputation: 119
I faced similar issue trying to delete docker folder for cleanup, the below simple trick worked for me
Pre-requisite : Needs git bash to be installed
I think the above workaround will also work with WSL terminal, but haven't tested myself
Upvotes: 0
Reputation: 638
I use WSL 2 and this helped me: Open your PowerShell and enter the following
PS C:\tmp> diskpart
Microsoft DiskPart version 10.0.19041.1
Copyright (C) Microsoft Corporation.
On computer: *****
DISKPART> select vdisk file="C:\Users\<UID>\AppData\Local\Docker\wsl\data\ext4.vhdx"
DiskPart successfully selected the virtual disk file.
DISKPART> compact vdisk
100 percent completed
DiskPart successfully compacted the virtual disk file.
Try wsl --shutdown
in PowerShell if it claims another process uses this disk
Upvotes: 4
Reputation: 1305
Since Docker 1.13 (January 2017), Docker has some new canonical pruning subcommands (use with care):
However, Docker Desktop has had some sketchy upgrades that left things behind, which required manual file removal or "factory resets" for some folks.
rm -rf ~/Library/Containers/com.docker.docker/Data/*
)Upvotes: 37
Reputation: 929
From a powershell window:
docker system prune -a -f
net stop com.docker.service
taskkill /F /IM "Docker Desktop.exe"
stop-vm DockerDesktopVM
Optimize-VHD -Path "C:\ProgramData\DockerDesktop\vm-data\DockerDesktop.vhdx" -Mode Full
start-vm DockerDesktopVM
start "C:\Program Files\Docker\Docker\Docker Desktop.exe"
net start com.docker.service
Upvotes: 12
Reputation: 2848
Try
icacls "C:\ProgramData\Docker" /T /C /grant Administrators:F
as administrator
Upvotes: 1
Reputation: 4381
Just use prune
command for docker system
and it will clean up every thing just like this
$ docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache Are you sure you want to continue? [y/N] y
In Docker 17.06.1 and higher, you can add the --volumes
flag for docker system prune
to prune volumes not used by at least one container.
For more details https://docs.docker.com/config/pruning/#prune-everything
Upvotes: 7
Reputation: 4909
Download docker-ci-zap.exe
from https://github.com/jhowardmsft/docker-ci-zap and then run it in powershell with admin priviledge:
.\docker-ci-zap.exe -folder "C:\ProgramData\docker"
Reference: https://github.com/moby/moby/issues/26873
Upvotes: 5
Reputation: 57
If still relevant. I ran into the same thing.
Try the command
docker rmi
In my case problem was in that I tried execute it in linux containers mode.
When I switched into windows containers this command executing removed all content of this folder.
Upvotes: 1