Setting memory and CPU limits in docker-compose
Why it matters
One service with a memory leak takes the whole host down with every other container on it. A limit turns that into one restarted container.
How to fix it
Add to each service:
deploy:
resources:
limits:
memory: 512M
cpus: "0.5"
Does your repository pass this check?
Free for public GitHub repositories, no account needed. 50+ DevOps and security checks in about ten seconds.