Last active
May 3, 2018 07:42
-
-
Save ike/48d9421dd8b3480a0701f6c1c7ac76a3 to your computer and use it in GitHub Desktop.
docker-up prune
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swarm = DockerSwarm.new() | |
service = Service.new(config.json) | |
Prune(images? = false, containers? = false, machines? = false) | |
if images? | |
images = getServiceImages(service) | |
for image in images | |
// Check if image is dangling (old version + not used), then destroy | |
unless isDangling(image) | |
image.destroy() | |
if containers? | |
containers = getServiceContainers(service) | |
for container in containers | |
// Check if container is stopped or orphaned, then destroy | |
unless isStopped(container) or isOrphaned(container) | |
container.destroy() | |
if machines? | |
... | |
PruneServices() | |
services = swarm.getServices() | |
for service in services | |
// I assume this would include some business rules, like "is this service for a customer in good standing", as well as | |
// ops checks like "is this service orphaned for some reason" | |
unless isNeeded(service) | |
service.backupSSB() | |
service.destroy() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment