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

      Top 10 Use Cases of Vibe Coding in Large-Scale Node.js Applications

      September 3, 2025

      Cloudsmith launches ML Model Registry to provide a single source of truth for AI models and datasets

      September 3, 2025

      Kong Acquires OpenMeter to Unlock AI and API Monetization for the Agentic Era

      September 3, 2025

      Microsoft Graph CLI to be retired

      September 2, 2025

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025

      ASUS built a desktop gaming PC around a mobile CPU — it’s an interesting, if flawed, idea

      September 4, 2025

      Hollow Knight: Silksong arrives on Xbox Game Pass this week — and Xbox’s September 1–7 lineup also packs in the horror. Here’s every new game.

      September 4, 2025

      The Xbox remaster that brought Gears to PlayStation just passed a huge milestone — “ending the console war” and proving the series still has serious pulling power

      September 4, 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

      Magento (Adobe Commerce) or Optimizely Configured Commerce: Which One to Choose

      September 4, 2025
      Recent

      Magento (Adobe Commerce) or Optimizely Configured Commerce: Which One to Choose

      September 4, 2025

      Updates from N|Solid Runtime: The Best Open-Source Node.js RT Just Got Better

      September 3, 2025

      Scale Your Business with AI-Powered Solutions Built for Singapore’s Digital Economy

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

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025
      Recent

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025

      ASUS built a desktop gaming PC around a mobile CPU — it’s an interesting, if flawed, idea

      September 4, 2025

      Hollow Knight: Silksong arrives on Xbox Game Pass this week — and Xbox’s September 1–7 lineup also packs in the horror. Here’s every new game.

      September 4, 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

    How to Make Bluetooth on Android More Reliable

    September 4, 2025
    Development

    Learn Mandarin Chinese for Beginners – Full HSK 1 Level

    September 4, 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-52880 – Komga EPUB XSS Attack Vector

    Common Vulnerabilities and Exposures (CVEs)

    People’s Republic of China cyber threat activity: Cyber Threat Bulletin

    Security

    Fewer Ideas: An Unconventional Approach To Creativity

    Tech & Work

    CVE-2025-49441 – WordPress Map Plugins Interactive Regional Map of Florida Authorization Bypass

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Development

    ENISA and European Commission Launch €36 Million EU Cybersecurity Reserve to Strengthen Digital Resilience

    August 29, 2025

    The European Union Agency for Cybersecurity (ENISA) and the European Commission have signed a landmark…

    CVE-2025-5249 – PHPGurukul News Portal Project SQL Injection Vulnerability

    May 27, 2025

    How to make sure Adobe Flash is up-to-date and enabling it on-demand

    April 9, 2025

    Modules in Terraform: Creating Reusable Infrastructure Code

    July 21, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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