testcontainers / testcontainers/testcontainers-java
BrowserWebDriverContainer does not start if shared memory not set under WSL2
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 8.7k
- Forks
- 1.9k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 9
Descripción
Hi there,
I've been trying to run my UI Tests under Windows out of curiosity. If I use the old Docker engine for Windows, everything works fine (as does under "real" Linux, for that matter). When employing the WSL2 based engine, the tests fail because the container for the web driver (image selenium/standalone-firefox-debug:3.141.59) does not start.
I've been creating the container like so:
private BrowserWebDriverContainer<?> container = new BrowserWebDriverContainer<>()
.withCapabilities(new FirefoxOptions());
If I try to run the tests with WSL 2-based Docker -- no matter if from the IDE or with mvn -- I get the following Exception:
com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"error while creating mount source path '/dev/shm': mkdir /dev/shm: file exists"}
The same happens if I issue docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox from Powershell. It does NOT happen if I issue it under WSL 2's Bash.
FYI: As a workaround, I manually set shared memory on container instantiation:
private BrowserWebDriverContainer<?> container = new BrowserWebDriverContainer<>()
.withSharedMemorySize(2147483648L)
.withCapabilities(new FirefoxOptions());
When preemptively setting shm I can bypass the bind creation in BrowserWebDriverContainer:
if (this.getShmSize() == null) {
this.getBinds().add(new Bind("/dev/shm", new Volume("/dev/shm"), AccessMode.rw));
}
Now, I'm not sure whether this presents as something you can or even want to fix as it seems like it's WSL 2-backed Docker's fault. But here we are. ;)
Besides that, thanks for Testcontainers, it's been nothing but great so far.
Cheers,
rmnbhm
WSL Version: 2
WSL Distro: Ubuntu 18.04
Docker Engine Version: 19.03.8
Windows 10 Version: 2004 (Build 19041.173)
TestContainers Version: 1.12.5
Image used: selenium/standalone-firefox-debug:3.141.59
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con BrowserWebDriverContainer y su configuración del bind mount de memoria compartida, especialmente con la condición de getShmSize() mostrada en el informe. Reproduce el fallo del montaje de /dev/shm con WSL2 Docker y la imagen de selenium; después, verifica que el contenedor se inicia sin requerir que los llamadores establezcan explícitamente la memoria compartida.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- docker, java
- Área
- testing
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100