Skip to content

Mayonnaisu/docker-purge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Purged

Docker Purge

PowerShell script to delete all Docker Desktop objects, supposedly

About

Warning

This simple script will delete all your Docker containers, images, volumes, & builds, including their caches, and then compact docker_data.vhdx automatically. So use at your own risk!

That's what I'd like to say... But even with all of these prune commands, there are some persistent builds that can't be deleted! In that case, you gotta remove them manually from the GUI: Builds > Build history. Select builds, then remove.

Prerequisites

  1. Docker Desktop with WSL2
  2. Windows PowerShell

    Tested with:

    • Docker Desktop 4.46.0
    • WSL2 2.6.1.0
    • PowerShell 5.1 & 7.5.3 (🤔 hmm I gotta update this)

Usage

Method 1 (Recommended as more secure)

  1. Open PowerShell.
  2. Enter the following command:
powershell -ExecutionPolicy ByPass -File PATH\TO\THIS\SCRIPT

Replace PATH\TO\THIS\SCRIPT with its actual path. For example,
C:\Users\mayonnaisu\Download\docker-purge-main\docker-purge.ps1

  1. Select "Yes" when UAC prompt pops up.

Method 2 (Convenient but less secure)

  1. Open PowerShell as Administrator.
  2. Change PowerShell execution policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
  1. Enter y or yes.

Note

You don't need to do step 1-3 again the next time you run this script unless you have changed the execution policy to "Restricted" again.

  1. Right click on this script.
  2. Select "Run with PowerShell".
  3. Select "Yes" when UAC prompt pops up.

Extra Info

You need to regularly compact the .vhdx file, used by Docker Desktop to store its data. It's because while it can expand automatically, it can't shrink automatically (as of now) even after you have removed a lot of data from the virtual disk.

About

PowerShell script to delete all Docker Desktop objects, supposedly.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors