Failed to limit memory with docker compose

1k views Asked by At

My server has 2GB mem

I launched 2 containers in the server with docker-compose

Although I set the memory limiti, but it seems not work

docker-compose

hub:
  mem_limit: 256m
  image: selenium/hub
  ports:
    - "4444:4444"
test:
  mem_limit: 256m
  build: ./
  links:
    - hub
  ports:
    - "5900"      
2

There are 2 answers

0
Gaspar Chilingarov On

This is not documented anywhere in docker-compose, but you can pass any valid system call setrlimit option in ulimits.

So, you can specify in docker-compose.yaml

ulimits: as: hard: 130000000 soft: 100000000

memory size is in bytes. After going over this limit your process will get memory allocation exceptions, which you may or may not trap.

0
guangyan wang On

I'm not sure about this but try set mem_limit to 256000000 without using 'm'