Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Docker cleanup to preserve caching #6631

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

neubig
Copy link
Contributor

@neubig neubig commented Feb 5, 2025

This PR optimizes the Docker cleanup strategy to better preserve caching while still managing disk space effectively.

Changes:

  • Replace aggressive docker system prune with targeted cleanup:
    • Only remove dangling (untagged) images
    • Only remove containers stopped for >1h
    • Only remove unused volumes
  • Keep build cache for frequently used base images

This should help maintain better build performance (previous approach was taking ~12 minutes vs the usual 3-6 minutes) while still preventing disk space issues like the one seen in #6346.


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:2218e72-nikolaik   --name openhands-app-2218e72   docker.all-hands.dev/all-hands-ai/openhands:2218e72

- Add disk space monitoring before build, after build, and after hash verification
- Add Docker cleanup steps to free up space after major operations
- Monitor largest files and directories to identify space usage
- Use docker system prune and builder prune to clean up unused resources
- Replace aggressive docker system prune with targeted cleanup
- Only remove dangling images and unused containers/volumes
- Keep build cache for frequently used base images
- Add time filter to only remove old containers (>1h)

This should maintain better build performance while still managing disk space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants