Expected Outcome
Dangling Docker containers,volumes and images are automatically pruned daily, helping to promote a healthy OverlayFS performance.
Prerequisites
- Linux System with
crond
service enabled - Root access
Procedure
- SSH into the Terraform Enterprise host and switch to the
root
user. NOTE: If utilizing either a custom worker image or a custom agent image skipdocker image prune -f
to avoid potentially having to pull the image manually.
# Run as root
cat > /etc/cron.daily/docker-prune << EOF
#!/bin/bash
echo "Pruning dangling Docker containers"
docker container prune -f
echo "Pruning dangling Docker volumes"
docker volume prune -f
echo "Pruning dangling Docker images"
docker image prune -f
> EOF - Make the file executable.
# Enable executable bit
chmod +x /etc/cron.daily/docker-prune - Confirm the script will run as expected.
run-parts /etc/cron.daily
# Example output
/etc/cron.daily/docker-prune:
Pruning dangling Docker containers
Total reclaimed space: 0B
Pruning dangling Docker volumes
Total reclaimed space: 0B
Pruning dangling Docker images
Total reclaimed space: 0B