I am trying to use AWS EC2 Container Service (ECS) in order to run a dockerized webdriver (Selenium) Grid. According to 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 long running tests using the chrome browser on the selenium-node-chrome image.
On my EC2 instance, when I do a
df -h
I see that /dev/shm exists and has 3.7Gb of available free space. But if I mount the volume to my chrome-node container using the -v /dev/shm:/dev/shm property, the browser is not even coming up when I run a test. But if I mount the parent /dev directory, tests seem to run for a few seconds and then I get the "Unable to reach Browser exception" because the browser is then getting closed (I was able to confirm this through VNC Viewer). This makes me realize that mounting a volume through ECS interface / api is not gonna help.
If I directly start docker without going through the ECS route by passing the --shm-size property like
docker run --shm-size=2500m ....
The tests seem to run without any trouble.
But, ECS clearly does not support the --shm-size property as of now. So how to fix or work around this issue and still use ECS to pass the --shm-size property? Is avoiding the usage of ECS the only way here or is there any other better way?
A workaround:
Add below (EntryPoint) command as the last line in your 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 have tested this change in local docker, although it requires --privileged or at least --cap-add SYS_ADMIN. I have yet to test it on AWS.