Oops! Storage running out in docker swarm cluster nodes…
Published in
1 min readApr 12, 2022
If you are running your Docker containers in docker swarm and have observed that you are gradually running out of disk space.
There is a simple explanation for this.
Whenever a docker container is running, there are logs files being generated and stored within the container. After a while, the container blows up in size.
In order to prevent this, you can update your Stack service with a small change like below.
logging:
driver: json-file
options:
max-size: "1m"
max-file: "5"
What this basically enforces, is to have a maximum size of 1 megabyte and a maximum of 5 files to keep. Of course, you can change these values to your needs.
A full example of how to use this is seen below.
version: "3"services:
apache:
image: httpd:2.4
logging:
driver: json-file
options:
max-size: "1m"
max-file: "5"
deploy:
resources:
limits:
cpus: "0.50"
memory: "512M"
reservations:
cpus: "0.25"
memory: "256M"