7

I have run my docker container containing RabbitMQ instance. Ia have used docker run command with three parameters (among others):

-m 300m

--kernel-memory="300m"

--memory-swap="400m"

docker stats shows:

> CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %   NET I/O               BLOCK I/O 
> 1f50929f8e4e        0.40%               126.8 MB / 349.2 MB   36.30%  908.2 kB / 1.406 MB   24.69 MB / 1.114 MB

I have expected that RabbitMQ will see only 300MB of RAM memory, but high watermark visible on Rabbit UI shows 5,3GB. My host has 8GB available so, probably RabbitMQ read memory size from host.

Michał P.
  • 140
  • 2
  • 12
  • It can _see_ the host memory, but it can't _use_ it: check http://stackoverflow.com/questions/20096632/limit-memory-on-a-docker-container-doesnt-work – mustaccio Nov 25 '16 at 17:09
  • As I understand RabbitMQ will manage their memory in reference to host memory. It means that it will simply take more memory that is available on container and crashed. If Rabbit could use docker memory limit as reference, everything should work fine (as expected). – Michał P. Nov 25 '16 at 19:33
  • 1
    Well, you can explicitly set RabbitMQ memory threshold: https://www.rabbitmq.com/memory.html. Since Docker 1.8 cgroup configuration is available inside the container via `/sys/fs/cgroup`, so you can script something up. – mustaccio Nov 25 '16 at 19:49
  • Thank you, I know that it is possible to do it explicity. It looks it is an only way to resolve my issue. – Michał P. Nov 26 '16 at 10:07
  • I also see this behavior that is not in aggreement wtih the [documentation](https://github.com/docker-library/docs/tree/master/rabbitmq#memory-limits). ` $docker run --rm --memory 256m --name rmq rabbitmq:3.9.28-management-alpine ; $ docker exec rmq sh -c "rabbitmqctl status |grep -C1 -i memory; cat /sys/fs/cgroup/memory/memory.limit_ in_bytes | awk '{print \$0/1024/1024/1024\"G\"}' "; Memory Total memory used: 0.1501 gb Calculation strategy: rss Memory high watermark setting: 0.4 of available memory, computed to: 6.5352 gb 0.25G ` – dosmanak Aug 07 '23 at 11:34

0 Answers0