How do I limit the memory resource of a group of docker containers? How do I limit the memory resource of a group of docker containers? docker docker

How do I limit the memory resource of a group of docker containers?


i think there are two ways to solve your problem.

you could try to increase the memory usage of each single container or for the compose itself.

like you mentioned you can pass each Dockerfile in your compose the option --memory or --memory-swap.

in your docker-compose.yml file you can set option/parameters to limit or increase the resources.

e.g.:

version: '3'services:  redis:    image: redis:alpine    deploy:      resources:        limits:          cpus: '0.50'          memory: 50M        reservations:          cpus: '0.25'          memory: 20M

you can do this for every container you want to compose.

DOCS: https://docs.docker.com/compose/compose-file/#resources