Amazon ECS support for -shm-size in docker

I am trying to use AWS EC2 Container Service (ECS) to run a web reseller grid (Selenium). According to the docker-selenium github page, we need to either add some shared memory or mount a volume to the docker container if we want to run tests for a long time using the Chrome browser on selenium-node-chrome .

In my EC2 instance, when I do

 df -h 

I see that /dev/shm exists and has 3.7Gb of available free space . But if I mount the volume in my chrome-node container using the -v /dev/shm:/dev/shm , the browser doesnโ€™t work even when the test runs. But if I mount the parent directory /dev , the tests seem to run for a few seconds, and then I get "Unable to reach browser exception" because the browser closes (I was able to confirm this through the VNC Viewer). This makes me realize that setting the volume through the ECI / api interface will not help.

If I directly launched docker without going through the ECS route, passing the --shm-size property, for example

 docker run --shm-size=2500m .... 

Tests seem no problem.

But, ECS does not explicitly support the --shm-size property at the moment. So, how do I fix or work around this problem and still use ECS to pass the --shm-size property? Avoid using ECS โ€‹โ€‹only here or is there another better way?

+6
source share
1 answer

Workaround:

Add below (EntryPoint) command as last line in dockerfile

 ENTRYPOINT shm_dir=/dev/shm;umount $shm_dir;mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=*<size eg. 500m,1Gb>* shm $shm_dir && /bin/bash 

I tested this change in the local docker and it works as expected (another aws test).

Thanks to Anor for this workaround. Source: Anor Blog

0
source

Source: https://habr.com/ru/post/1015700/


All Articles