Skip to content

Instantly share code, notes, and snippets.

Last active May 4, 2023 00:37
What would you like to do?
How to delete `C:\ProgramData\Docker` and fixing "Access denied" errors

Still an issue in March 2023. Welcome to the future of web development. Take this Gist 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:

  • kills all docker containers, if any
  • take ownership of all docker files within C:\ProgramData\Docker
  • remove C:\ProgramData\Docker by invoking cmd, because microsoft powershell is struggling to delete symlinks, of which docker has many

grab a coffee....

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

Copy link

Thanks, docker got corrupted and wont start. Tried uninstall and install but that didn't work. Used the script to clean docker and install again. Im up and running with container again.

Copy link

Thanks, worked nicely for me

Copy link

proBaxia commented Dec 9, 2022

Thank you very much it works for me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment