Is it safe to run 'docker system prune' on a cluster node?


#1

Topic says it really.

Also along these lines, should I expect Rancher to keep containers tidy on nodes, or do I need to clean up every now and then? I ask since I just rebooted a node and ‘docker ps -a’ shows there are several exited containers that have apparently been replaced by newer containers with similar names.


#2

Docker does not do any housecleaning on containers/images/volumes/networks. That is on the administrator to take care of. I have a cron job set up weekly that does docker system prune -af on all of my Kubernetes hosts.


#3

Kubernetes has its own garbage collection system: https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/

It’s probably not a good idea for you to run stuff yourself, as it could potentially confuse Kubernetes. Instead, configure the Kubernetes garbage collector directly.


#4

Thanks for the responses. Knowing that gc is happening on the k8s level w/ kubelet is just what I needed! Also, thanks for the link so I can understand it’s behavior and tweaks if needed.