Skip to content

Instantly share code, notes, and snippets.

@ebell451
Forked from nicolaskopp/killDocker.md
Created October 27, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebell451/a316ab789f56ba624e27c12c6d45aa0c to your computer and use it in GitHub Desktop.
Save ebell451/a316ab789f56ba624e27c12c6d45aa0c to your computer and use it in GitHub Desktop.
How to delete `C:\ProgramData\Docker` and fixing "Access denied" errors

Still an issue in May 2021. 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.

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