Skip to content

Instantly share code, notes, and snippets.

@nicolaskopp
Last active March 14, 2024 10:57
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918 to your computer and use it in GitHub Desktop.
Save nicolaskopp/de9fff4889d0ddf4c79da7ebc9e8b918 to your computer and use it in GitHub Desktop.
How to delete `C:\ProgramData\Docker` and fixing "Access denied" errors

How to delete C:\ProgramData\Docker and fixing "Access denied" errors

Still an issue in January 2024. 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.

@Saffienn
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.

@venivediveci
Copy link

Thanks, worked nicely for me

@proBaxia
Copy link

proBaxia commented Dec 9, 2022

Thank you very much it works for me too

@jon-at-linkforge
Copy link

Thanks!

@yul14nrc
Copy link

yul14nrc commented Oct 5, 2023

Thanks!

@huysuper
Copy link

Thank!

@pierre-simonet
Copy link

Thanks !

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