Clear unused Docker data
- macOS onlyThis script improves your privacy on macOS
- Single actionThis page belongs to a script, containing basic changes to achieve a task.
- Impact: Medium
System Functionality / Data Loss Risk: Moderate
This action improves privacy with minimal impact when you run the recommended script.
This action improves privacy with some impact when you run the recommended script. - Bash (Shell script)These changes use macOS system commands to update your settings.
- Administrative (sudo) access requiredThis script requires privilege access to do the system changes
- Fully reversible
You can fully restore this action (revert back to the original behavior) using this website.
The restore/revert methods provided here can help you fix issues.
Overview
This script frees up disk space, but also improves user privacy by:
-
Removal of stopped containers: Containers often run applications or services that might process sensitive or personal data. Even if a container is stopped, its filesystem remains intact, and potentially sensitive data inside it can be accessed. By removing stopped containers, we eliminate this potential privacy risk.
-
Deletion of unused images: Images can sometimes contain sensitive information, especially if they were built from
Dockerfile
s that copied local files or were used in scenarios where sensitive data was processed. Deleting unused images ensures that any inadvertent sensitive information embedded in those images is eradicated. -
Cleanup of network configurations: Networks, especially custom ones, can contain configurations that reveal details about system architecture, inter-container communication, or even hardcoded secrets. Removing unused networks mitigates risks associated with lingering, outdated, or insecure configurations.
-
Elimination of build cache: The Docker build process uses a cache to speed up image creation. This cache can contain remnants of previous builds, including potentially sensitive data or files. Pruning the build cache ensures that these remnants are deleted, further safeguarding privacy.
-
Footprint reduction: By consistently pruning unused Docker objects, the overall footprint of Docker on the system is reduced. This makes it harder for malicious actors to exploit any lingering or overlooked vulnerabilities in the system or Docker itself.
This script runs docker system prune -af
command to clean up unused Docker data 1.
Specifically, the command will 1:
- Remove all stopped containers.
- Remove all networks not used by at least one container.
- Remove all images not used by any container.
- Remove all build cache.
This script is only recommended if you understand its implications.
Some non-critical or features may no longer function correctly after running this script.
This script can be fully reversed to restore changes if something goes wrong.
Sources
- docker system prune. Docker Documentation. (2023).
Original: https://docs.docker.com/engine/reference/commandline/system_prune
Archived: https://web.archive.org/web/20230810171526/https://docs.docker.com/engine/reference/commandline/system_prune/
Apply Now
Choose one of three ways to apply:
Help
How to apply or restore "Clear unused Docker data" using script
- ≈ 3 min to complete
- Tools: Web Browser
- Difficulty: Medium
- ≈ 5 instructions
- 1
Download
Download the script file by clicking on thebutton above.
Use button above to restore changes. - 2
Keep the file
If warned by your browser, keep the file. - 3
Open
Open the downloaded file. - 4
Exit
Once it's done, press any key to exit the window. - 5
Restart
Restart your computer for all changes to take effect.
Apply with privacy.sexy
Guided, automated application with safety checks- Recommended for most users
- Includes safety checks
- Free
- Open-source
- Popular
- Offline/Online usage
Help
How to apply or restore "Clear unused Docker data" using privacy.sexy
- ≈ 3 min to complete
- Tools: privacy.sexy
- Difficulty: Simple
- ≈ 4 instructions
- 2
Choose script
- Search for the script name: Clear unused Docker data
- Check the script by clicking on the checkbox.
- 3
Run
Click on ▶️ Run button at the bottom of the page.This button only appears on desktop version (recommended). On browser, use 💾 Save button.
- Apply
- Revert
if type "docker" &> /dev/null; then
docker system prune -af
fi
bnVsbA==
Help
How to apply or restore "Clear unused Docker data" using commands
- ≈ 2 min to complete
- Tools: Terminal app
- Difficulty: undefined
- ≈ 3 instructions
- 1
Open terminal
Open Terminal app. - 2
Copy code
Copy the code: - 3
Paste & run
Paste the code into Terminal and press Enter to run.Some changes require a system restart to take effect
Similar Guides
Wider Goal
Guides below includes this guide to achieve a wider goal.See other more general settings that includes this one as one of its actions.
These plans combine multiple privacy settings, including this one, for stronger protection.
- Clear third-party application data
- Privacy cleanup
MacOS sensitive data privacy: clear third-party application data in a few steps on this option that walks you through how to avoid invasive data exposure and impro...
This specification: privacy cleanup — lays out a systematic approach to how to lock down private information as part of sensitive data privacy protection on macOS...
Same Goal
Other guides in Clear third-party application dataSee settings that are in the same category as this guide.
Using other actions in the same category may help you achieve your goal better.
About the Creators
These people have authored this documentation and written its scripts:
Reviewed By
This guide has undergone comprehensive auditing and peer review:Expert review by undergroundwires
- Verified technical accuracy and editorial standards
- Assessed system impact and user privacy risks
Public review by large community
- Privacy enthusiasts and professionals peer-reviewed
- Millions of end-users tested across different environments
History
We continually monitor our guides, their impact and all other privacy options. We update our guides when new information becomes available. On every update, we publicly store who made the change, what has been changed, why the change was made and when the change was made.