We were trying to move our Selenium tests into a docker container and were getting the above error response. First Google suggested increasing the memory of the container to 2G. We increased it to 3G to no effect. Deeper Googling then suggested increasing shared memory. Initially, it was 64m. We raised it to 256m and it magically worked! Our script for creating the container:
docker build . -f docker/Dockerfile --label cdx_selenium -t cdx_selenium
docker run --shm-size=256m -m3000m --cpus=4 --privileged -d --name cdx_selenium cdx_selenium
docker exec cdx_selenium bash -c 'systemctl daemon-reload && systemctl enable xvfb.service && systemctl start xvfb.service'
We also needed to install dbus-x11. In theory we shouldn’t need to do the systemctl outside the Dockerfile.