Chrome with selenium, python and docker

Sometimes, when I execute the Chrome inside a docker container I receive the error below:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed

It is caused because Chrome uses the /dev/shm to share memory and the docker, by default, set 64MB for this partition.

Here, I will describe how to reproduce this error and how to resolve it.

How to reproduce

To reproduce this error, we need to create a docker image with chrome and python. Then, I created this Dockerfile which uses a multi-stage build to install the chrome and the python.

[Read More]