Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Reclaim Space: Delete Docker Orphan Layers

    Reclaim Space: Delete Docker Orphan Layers

    July 18, 2025

    If you’re using Sitecore Docker containers on Windows, you’ve probably noticed your disk space mysteriously shrinking over time. I recently encountered this issue myself and was surprised to discover the culprit: orphaned Docker layers – leftover chunks of data that no longer belong to any container or image.

    My Setup

    This happened while I was working with Sitecore XP 10.2 in a Dockerized environment. After several rounds of running’ docker-compose up’ and rebuilding custom images, Docker started hoarding storage, and the usual’ docker system prune’ didn’t fully resolve the issue.

    That’s when I stumbled upon a great blog post by Vikrant Punwatkar: Regain disk space occupied by Docker

    Inspired by his approach, I automated the cleanup process with PowerShell, and it worked like a charm. Let me walk you through it.

    So, What Are Orphan Docker Layers?

    Docker uses layers to build and manage images. Over time, when images are rebuilt or containers removed, some layers are left behind. These “orphan” layers hang around in your system, specifically under:

    C:ProgramDataDockerwindowsfilter

    They’re not in use, but they still consume gigabytes of space. If you’re working with large containers, such as Sitecore’s, these can add up quickly.

    Step-by-Step Cleanup with PowerShell

    I broke the cleanup process into two simple scripts:

    1. Identify and optionally rename orphan layers
    2. Delete the renamed layers after fixing permissions

    Script 1: Find-OrphanDockerLayers.ps1

    This script compares the layers used by active images and containers against what’s actually on your disk. Anything extra is flagged as an orphan. You can choose to rename those orphan folders (we add -removing at the end) for safe deletion.

    What it does

    • Scans the image and container layers
    • Compared with the actual Docker filesystem folders
    • Identifies unused (orphan) layers
    • Calculates their size
    • Renames them safely (optional)

    A. Download PowerShell script and execute (as Administrator) with the parameter -RenameOrphanLayers

    B. To Run:

    .Find-OrphanDockerLayers.ps1 -RenameOrphanLayers

    C. Sample Output:

    WARNING: YOUR-PC - Found orphan layer: C:ProgramDataDockerwindowsfilterabc123 with size: 500 MB
    ...
    YOUR-PC - Layers on disk: 130
    YOUR-PC - Image layers: 90
    YOUR-PC - Container layers: 15
    WARNING: YOUR-PC - Found 25 orphan layers with total size 4.8 GB
    
    

    This provides a clear picture of the space you can recover.

    Delete After Stopping Docker

    Stop Docker completely first using the below PowerShell command, or you can manually stop the Docker services:

    Stop-Service docker

    Script 2: Delete-OrphanDockerLayers.ps1

    Once you’ve renamed the orphan layers, this second script deletes them safely. It first fixes folder permissions using takeown and icacls, which are crucial for system directories like these.

    A. Download the PowerShell script and execute (as Administrator)

    B. To Run:

    .Delete-OrphanDockerLayers.ps1

    C. Sample Output:

    Fixing permissions and deleting: C:ProgramDataDockerwindowsfilterabc123-removing
    ...
    

    Simple and effective — no manual folder browsing or permission headaches.

    End Result: A Cleaner, Lighter Docker

    After running these scripts, I was able to recover multiple gigabytes of storage, and you’ll definitely benefit from this cleanup. If you’re frequently working with:

    • Sitecore custom Docker images
    • Containerized development setups
    • Large volume-mounted projects

    Pro Tips

    • Run PowerShell as Administrator – especially for the delete script.
    • Don’t delete folders manually – rename first to ensure safety.
    • Use -RenameOrphanLayers only when you’re ready to clean up. Otherwise, run the script without it for a dry run.
    • Consider scheduling this monthly if you’re actively building and tearing down containers.

    Credit Where It’s Due

    Huge thanks to Vikrant Punwatkar for the original idea and guidance. His blog post was the foundation for this automated approach.

    Check out his post here: Regain disk space occupied by Docker

    Final Thoughts

    If your Docker setup is bloated and space is mysteriously disappearing, try this approach. It’s quick, safe, and makes a noticeable difference – especially on Windows, where Docker’s cleanup isn’t always as aggressive as we’d like.

    Have you tried it? Got a different solution? Feel free to share your thoughts or suggestions for improvement.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleTop 10 Threat Intelligence Platforms in ANZ: 2025 Guide for Security Teams
    Next Article Model predicts long-term effects of nuclear waste on underground disposal systems

    Related Posts

    Development

    GPT-5 is Coming: Revolutionizing Software Testing

    July 22, 2025
    Development

    Win the Accessibility Game: Combining AI with Human Judgment

    July 22, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-46406 – “Schneider Electric Command Centre Server Privilege Escalation”

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-5436 – Multilaser Sirius RE016 Information Disclosure Remote Vulnerability

    Common Vulnerabilities and Exposures (CVEs)
    Adobe Patches 11 Critical ColdFusion Flaws Amid 30 Total Vulnerabilities Discovered

    Adobe Patches 11 Critical ColdFusion Flaws Amid 30 Total Vulnerabilities Discovered

    Development

    Bolt.new: Web Creation at the Speed of Thought

    News & Updates

    Highlights

    CVE-2025-3092 – Cisco WebEx Brute Force User Enumeration

    June 24, 2025

    CVE ID : CVE-2025-3092

    Published : June 24, 2025, 9:15 a.m. | 1 hour, 38 minutes ago

    Description : An unauthenticated remote attacker can enumerate valid user names from an unprotected endpoint.

    Severity: 7.5 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    My favorite band and my favorite game studio are both weirdly taking me to the same fictional place this year

    June 10, 2025

    North Korean Konni APT Targets Ukraine with Malware to track Russian Invasion Progress

    May 13, 2025

    CVE-2025-49575 – Citizen is a MediaWiki skin that makes extensions

    June 12, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.