Automatically clean up docker on a windows machine?

We use the docker system prune command to remove all stopped containers, all unused networks, all dangling images, and build caches. We gonna execute the same command from the windows scheduled task to automatically clean up docker resources.

We are going to create a Windows Scheduled task with a PowerShell script to automatically delete all stopped containers, all dangling images, all unused networks, and build caches.

The following script will setup Scheduled tasks to be run at 3 am UTC which will prune docker.

Create a .ps1 file (ex: CreateDockerPruneWtask.ps1) with the below PowerShell script

Run the PowerShell script to create a Windows scheduled task, before running the script, please check the docker.exe file path, if needed change the path according to the docker installation.

You can verify the task in Task Scheduler. to launch Task Scheduler from PowerShell use taskschd command.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x