Skip to content

BrowserWebDriverContainer does not start if shared memory not set under WSL2 #2552

@romanboehm

Description

@romanboehm

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions