To avoid unused Docker images and volumes consuming the entire disk space, you can enable a clean-up cron job for old StackLight LMA containers and volumes. By default, the cron job runs daily at 6:00 a.m. and cleans stopped StackLight LMA images and containers that are older than one week.
To enable Docker garbage collection:
Open your Git project repository with the Reclass model on the cluster level.
In classes/cluster/<cluster_name>/stacklight/server.yml
, specify the
following parameter:
_param:
docker_garbage_collection_enabled: true
Optional. To change the default parameters, use:
linux:
system:
cron:
user:
root:
enabled: true
job:
docker_garbage_collection:
command: docker system prune -f --filter until=$(date +%s -d "1 week ago")
enabled: ${_param:docker_garbage_collection_enabled}
user: root
hour: 6
minute: 0
Log in to the Salt Master node.
Apply the following state:
salt -C 'I@docker:swarm' state.sls linux.system.cron