docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.87k stars 291 forks source link

Can't remove C:\ProgramData\Docker after uninstalling Docker #1544

Open davidmatson opened 6 years ago

davidmatson commented 6 years ago

Expected behavior

C:\ProgramData\Docker is gone or easy to remove.

Actual behavior

C:\ProgramData\Docker is present and can't be deleted via Windows explorer

Steps to reproduce the behavior

  1. Install Docker and use it with Windows containers.
  2. Uninstall Docker.
davidmatson commented 6 years ago

Looks like this has been an issue for a while: #191

danechambers commented 6 years ago

Not a long term solution to the problem, but there is a tool written to remove this folder: https://github.com/jhowardmsft/docker-ci-zap

see: https://github.com/moby/moby/issues/26873

You have to compile it, then run: .\docker-ci-zap.exe -folder "C:\ProgramData\docker"

Please be careful that you point this tool at the docker folder and NOT at ProgramData directly or any other folder with sensitive info. There is no undo button. Having said that, I have used this before personally and it works as advertised.

silentbobbert commented 6 years ago

This is a more straight forward way: https://success.docker.com/article/How_to_completely_remove_Docker_in_Windows_10

The installer should take care of this stuff. Its quite easy to run out of disk space on Windows 10 using docker, and not being able to free any up is insane.

terraslate commented 6 years ago

Actually it doesn't work. On my SSD drive docker has claimed 14GB for itself and it won't let me remove it. Its scandalous really, that's 14GB i'll never get back. Then i'm afriad to forcibly remove it given all the warnings about: wtf. What have they done in that directory? The script does not work - access to all files is denied run as administrator or not.

StingyJack commented 6 years ago

@terraslate - I was finally able to get rid of this stuff by running takeown /R /F * and then ICACLS * /T /Q /C /RESET from within the programdata\docker folder, At that point I could delete the folder using windows explorer delete and clicking Ignore for a few warnings.

ganesh-deshmukh commented 6 years ago

according to @StingyJack , I went to C:\Program Files\Docker, by opening cmd as administrator. run takeown /R /F * run ICACLS * /T /Q /C /RESET, but I could not delete Docker folder but it helped to remove error Access is denied. ** don't run in Program files folder, otherwise you will go to bootloop after restart, go to Docker folder first.

according to @silentbobbert, I checked his link and it worked. I created the small file with following content and saved with extension .ps1 in Program files folder, and right click on it and Run with Powershell.


    kill -force -processname 'Docker for Windows', com.docker.db, vpnkit, com.docker.proxy, com.docker.9pdb, moby-diag-dl, dockerd

    try {
        ./MobyLinux.ps1 -Destroy
    } Catch {}

    $service = Get-WmiObject -Class Win32_Service -Filter "Name='com.docker.service'"
    if ($service) { $service.StopService() }
    if ($service) { $service.Delete() }
    Start-Sleep -s 5
    Remove-Item -Recurse -Force "~/AppData/Local/Docker"
    Remove-Item -Recurse -Force "~/AppData/Roaming/Docker"
    if (Test-Path "C:\ProgramData\Docker") { takeown.exe /F "C:\ProgramData\Docker" /R /A /D Y }
    if (Test-Path "C:\ProgramData\Docker") { icacls "C:\ProgramData\Docker\" /T /C /grant Administrators:F }
    Remove-Item -Recurse -Force "C:\ProgramData\Docker"
    Remove-Item -Recurse -Force "C:\Program Files\Docker"
    Remove-Item -Recurse -Force "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Docker"
    Remove-Item -Force "C:\Users\Public\Desktop\Docker for Windows.lnk"
    Get-ChildItem HKLM:\software\microsoft\windows\currentversion\uninstall | % {Get-ItemProperty $_.PSPath}  | ? { $_.DisplayName -eq "Docker" } | Remove-Item -Recurse -Force
    Get-ChildItem HKLM:\software\classes\installer\products | % {Get-ItemProperty $_.pspath} | ? { $_.ProductName -eq "Docker" } | Remove-Item -Recurse -Force
    Get-Item 'HKLM:\software\Docker Inc.' | Remove-Item -Recurse -Force
    Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\Run -name "Docker for Windows" | Remove-Item -Recurse -Force
    #Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | ForEach-Object {Get-ItemProperty $_.PSPath} | Where-Object { $_.ToString().Contains("Docker for Windows.exe") } | Remove-Item -Recurse -Force $_.PSPath
    #Get-ItemProperty HKCU:\software\microsoft\windows\currentversion\UFH\SHC | Where-Object { $(Get-ItemPropertyValue $_) -Contains "Docker" }
StingyJack commented 6 years ago

@ganeshdeshmukh1612 - ProgramData not Program Files

ganesh-deshmukh commented 6 years ago

@StingyJack , you are right but, in my machine it is Program Files.

docker-robott commented 6 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

StingyJack commented 6 years ago

/lifecycle frozen

That bot is evil

davidmatson commented 6 years ago

/remove-lifecycle stale

uditjh commented 6 years ago

/lifecycle frozen

uditjh commented 6 years ago

/remove-lifecycle stale

uncodead commented 6 years ago

run command at cmd (admin mode): tasklist | grep docker Taskkill /PID <NUMBER> /F

Then manual delete

StingyJack commented 6 years ago

@uncodead - if docker is uninstalled, there should be no process still running. The problem is that you cant manually delete the files as they are owned by "Trusted Installer". (Also grep is not a windows command)

uncodead commented 6 years ago

@uncodead - if docker is uninstalled, there should be no process still running. The problem is that you cant manually delete the files as they are owned by "Trusted Installer". (Also grep is not a windows command)

even uninstalling Docker, docker.exe still runnig, so I run these commands (Also, I use cmder)

Davidkav86 commented 5 years ago

I ran into the same issue. Could not remove the folder using any of the methods mentioned above. I had already manually uninstalled all of the rest of the docker related folders. I tried using the script mentioned above, I tried this https://github.com/jhowardmsft/docker-ci-zap,I tried everything. To be honest I tried so many things before I deleted it that I am not sure exactly what combination of steps worked but i think it was this. I used the commands mentioned above to take ownership of the folder and files:: $ cd C:\ProgramData\docker $ takeown /R /F $ ICACLS /T /Q /C /RESET

Then I changed the name of the folder. Restarted my laptop and was able to delete it using Windows Explorer. Hopefully this might save someone some time.

dardano commented 5 years ago

I was able to delete all the files in safe mode with the Windows Explorer.

gurjotsingh30 commented 5 years ago

After uninstall the Docker , i am also facing the same issue i.e I am not able to delete the C:\ProgramData\DockerDesktop and C:\Program Files\Docker. Please suggest me the effective workaround to delete these folder . so, that i can reinstall the docker for window.

I used the commands as mentioned above to take ownership of the folder and files:: $ cd C:\ProgramData\docker $ takeown /R /F $ ICACLS /T /Q /C /RESET

Then I try to change the name of the folder but folder name not get changed neither i able to delete this folder. I also tried https://github.com/jhowardmsft/docker-ci-zap but not get any success.

ghost commented 4 years ago

Hi you are unable to delete docker folder because com.docker.backend.exe file in the resources folder is running in the task manager, to delete docker folder go to task manager and stop com.docker.backend.exe task and now delete the folder it worked for me.

grahamcarman commented 4 years ago

Not a solution, but interesting:

To investigate, I deleted all files I could inside ProgramFiles/Docker. After narrowing it down, I still couldn't delete just two files: docker.iso and docker-desktop.iso. Both of these live inside ProgramFiles/Docker/Docker/resources.

When I tried to delete / move / rename them individually, I got a new error message:

The action can't be completed because the file is open in System

So, these are being used by the actual Windows process System, and preventing the deletion of the whole Docker directory.

On the bright side, I was able to delete the whole folder when I booted into safe mode, as admin.

And if you need it, see this illustration of the problem.

sasidhar22 commented 4 years ago
  1. Click on windows button and search for " .docker " and delete its files.

  2. Just go to, C:\ProgramData\docker or C:\Program Files\docker . You would probably notice that the folder is empty. It worked for me, and hope it works for you too :)

maranov commented 4 years ago

For me, the problem was Event Service was accessing dockerd.

dockerBug

After I've restarted Event Service, the file was released.

GPHemsley commented 4 years ago

tasklist | grep docker

tasklist | findstr /I docker

TheRealIB commented 4 years ago

Honestly I was confused. I didn't know what to do even after seeing all the comments above and then I remembered that kali linux can cut through windows. So I created a linux bootable disk ...theN I deleted all the folders I didn't need..... I rebooted to windows and it worked

Cloudmersive commented 4 years ago

How is this bug still not fixed?

aradep commented 4 years ago

Ran into this issue after uninstalling docker. The image is still owned by... itself? image Couldn't delete it in safemode or by using elevated cmd to change permissions. after 4 hrs I figured i'd save myself the headache and just reinstall OS, so... 👍 guess that's a solution

Cloudmersive commented 4 years ago

This issue is a SEV1 because it impacts virtually all production customers, but has remained unfixed for years...

TheRealIB commented 3 years ago

Same thing happened to me. I created a kali linux bootable disk with a flashdrive, I was able to access and delete the stubborn file. Next, reboot back to normal windows. Problem solved!

Cloudmersive commented 3 years ago

Any update on this?

OraDotNetDev commented 3 years ago

We had this issue on an upgrade

Installing Docker Desktop Installer.exe...
[16:32:00.533] [InstallWorkflow] Installation failed
Exception type: System.Exception, Exception message: Unpacking failed: The process cannot access the file 'C:\Program Files\Docker\Docker\resources\docker-desktop.iso' because it is being used by another process., StackTrace:
   at CommunityInstaller.InstallWorkflow.d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CommunityInstaller.InstallWorkflow.d__23.MoveNext()

Following this StackOverflow answer using Resource Monitor, opened the CPU tab and searched for 'docker' in handles. The VM Worker Process vmwp.exe had a file handle open for docker-desktop.iso.

Tried to use the Hyper-V console to stop the VM, but the status was stucks at 1% and stopping and after a long time went back to running. The vmwp.exe process could be killed but the VM automatically restarted and the iso file was still locked.

Opened an elevated PowerShell Console and used the following script, to remove the VM locking the file.

Query back the VMs, in this case there was only one. The PID will be the same as the process locking the iso in Resource Monitor, kill the associated worker process and then immediately remove the VM before the worker process restarts. Once that was done docker could be upgraded/removed.

Used this blog post for details on handling the VM, not a Hyper-V expert is this issue here a corrupted VM?

#Requires -RunAsAdministrator

[DateTime] $now = Get-Date

# List HyperV VMs not powered off
Get-VM | 
    Where-Object State -notin ('Off','OffCritical') | 
    Format-Table -Property  Name, State, Uptime, Status, Version, Id -AutoSize

# List matching VM Worker processes
Get-Process -Name vmwp -IncludeUserName  |
     Format-Table -Property  Id, ProcessName, UserName, Responding,
                             @{Label='UpTime';Expression={'{0:hh\:mm\:ss\.fff}' -f ( ($now) - $_.StartTime)}}

# Query back the running VM
# **CHANGE** VM Name to the name of the VM queried above or use the -id parameter with the VM Id (GUID)
$VM = Get-VM -Name 'DockerDesktopVM'
$VM | Format-Table -Property  Name, State, Uptime, Status, Version, VMId -AutoSize

# Check the $VM variable returns the matching worker process 
Get-Process -Name vmwp -IncludeUserName | Where-Object UserName -match $VM.ID  

# Kill the process running the VM
Get-Process -Name vmwp -IncludeUserName | 
    Where-Object UserName -match $VM.ID |
    Stop-Process -Force -Verbose

$VM | Remove-VM -Force -Verbose

Think it may be the same as/related to #2348

hugosoftdev commented 3 years ago

I could resolve it (on windows) opening the task manager and stoping the process "docker.service", then i could delete the folder as an administrator.

rhythmnewt commented 3 years ago

This is insane that it's still an issue after two years! The uninstall option is completely broken on windows. I guess that's one way to keep your users - don't let them uninstall!

raman-nareika commented 3 years ago

tried after rebooting and successfully removed the folder

nicolaskopp commented 3 years ago

Still an issue in May 2021. Welcome to the future of web development. Take this comment to rest and calm down.

Here is how to delete C:\ProgramData\Docker.

  1. Uninstall docker the normal way (yeah you may have already done that)
  2. Copy this:
    # Leave swarm mode (this will automatically stop and remove services and overlay networks)
    docker swarm leave --force
    # Stop all running containers
    docker ps --quiet | ForEach-Object {docker stop $_}
    #just to be sure, sleep 5 seconds
    Start-Sleep -s 5
    #take ownership of docker files
    if (Test-Path "C:\ProgramData\Docker") { takeown.exe /F "C:\ProgramData\Docker" /R /A /D Y }
    if (Test-Path "C:\ProgramData\Docker") { icacls "C:\ProgramData\Docker\" /T /C /grant Administrators:F }
    #invoke cmd to delete docker files
    cmd /c rmdir /s /q "C:\ProgramData\Docker"
  1. save this as killDocker.ps1.
  2. go to start > powershell > run as administrator
  3. run .\killDocker.ps1

what this does:

grab a coffee....

after 10 minutes or so it should be done. You're welcome.

This is also available as a Gist.

sdg002 commented 3 years ago

Very stubborn problem. Was not able to delete even after uninstallation.

This solved:

Thank you @StingyJack

DeeBlueAngel commented 3 years ago

What worked for me - -Open Docker Desktop

buctllx commented 2 years ago

use dism++ can delete;

  1. open dism++
  2. select toolbox
  3. click file browser
  4. open c:/ProgramData/docker
  5. right click and delete
venivediveci commented 2 years ago

I found this which worked for me pretty smoothly: https://gist.github.com/nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918

essn commented 1 year ago

I noticed that even after I removed every file and folder, e.g. C:\ProgramData\Docker Desktop. Running the installer/uninstaller simply said "You're up to date".

This happened using PowerShell and Settings -> Apps -> Installed Apps too. It says it's installed but can't uninstall it. I tried installing previous versions, same thing.

I tooled around with the regedit and did find references to the "current version" that was "installed". I have only been using Windows for ~1 month and don't feel comfortable modifying the registry.

After a few days I bit the bullet, researched, and installed CCleaner after making sure it wasn't spyware (anymore, at least lol). I'm very suspicious of 3rd party applications and would not recommend them, but in my case, it cleaned out all references after which the installer worked. Praying I didn't do any damage with it.

Having to use a 3rd party application, messing with the registry, or running PS1 scripts feels dangerous and it is worrying that Docker Desktop seems to require it.

My 2 cents and I appreciate the hard work Docker has done, and the community support. If I figure out a better way, I will share it.

Edit: Formatting

BlackStar1991 commented 1 year ago

How to delete Docker if write - Access denied

nicolaskopp commented 1 year ago

@BlackStar1991 try this: https://gist.github.com/nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918

catmanjan commented 3 months ago

This is still an issue today

nicolaskopp commented 3 months ago

@catmanjan try this Gist:

https://gist.github.com/nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918

catmanjan commented 3 months ago

I actually did those steps manually, in doing so I managed to break docker desktop so badly I had to delete and recreate the VM LOL

On Tue, 6 Aug 2024, 9:57 pm Nicolas Kopp, @.***> wrote:

@catmanjan https://github.com/catmanjan try this Gist:

https://gist.github.com/nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918

— Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/1544#issuecomment-2271114601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBRBV52MWFHAEGVFVN35DZQC23JAVCNFSM6AAAAABL7O7R6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZRGEYTINRQGE . You are receiving this because you were mentioned.Message ID: @.***>

nicolaskopp commented 3 months ago

I actually did those steps manually, in doing so I managed to break docker desktop so badly I had to delete and recreate the VM LOL On Tue, 6 Aug 2024, 9:57 pm Nicolas Kopp, @.> wrote: @catmanjan https://github.com/catmanjan try this Gist: https://gist.github.com/nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918 — Reply to this email directly, view it on GitHub <#1544 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBRBV52MWFHAEGVFVN35DZQC23JAVCNFSM6AAAAABL7O7R6WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZRGEYTINRQGE . You are receiving this because you were mentioned.Message ID: @.>

whoops.