testcontainers / testcontainers/testcontainers-java
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under Linux
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Module
Selenium
Testcontainers version
2.0.5
Using the latest Testcontainers version?
Yes
Host OS
Ubuntu 26 LTS
Host Arch
x86-64
Docker version
Client:
Version: 29.6.2
API version: 1.55
Go version: go1.26.5
Git commit: dfc4efb
Built: Thu Jul 16 16:11:35 2026
OS/Arch: linux/amd64
Context: default
Server: Docker Desktop 4.83.0 (234302)
Engine:
Version: 29.6.2
API version: 1.55 (minimum version 1.40)
Go version: go1.26.5
Git commit: 3d80467
Built: Thu Jul 16 16:12:20 2026
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.2.5
GitCommit: e53c7c1516c3b2bff98eb76f1f4117477e6f4e66
runc:
Version: 1.3.6
GitCommit: v1.3.6-0-g491b69ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
When trying to reuse a BrowserWebDriverContainer under Linux, starting the container after stopping it once fails with com.github.dockerjava.api.exception.BadRequestException: Status 400: {"message":"Duplicate mount point: /dev/shm"}. Under Windows the following test succeeds - under Linux it does not.
Reproducer:
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.selenium.BrowserWebDriverContainer;
import org.testcontainers.utility.DockerImageName;
@Testcontainers
public class BuggyTest {
@Container
static final BrowserWebDriverContainer BROWSER_WEB_DRIVER_CONTAINER = new BrowserWebDriverContainer(
DockerImageName.parse("selenium/standalone-chrome:148.0-20260505")
);
@Test
void testContainer() {
BROWSER_WEB_DRIVER_CONTAINER.start();
BROWSER_WEB_DRIVER_CONTAINER.stop();
BROWSER_WEB_DRIVER_CONTAINER.start(); //this fails
BROWSER_WEB_DRIVER_CONTAINER.stop();
}
}
Relevant log output
org.testcontainers.containers.ContainerLaunchException: Container startup failed for image selenium/standalone-chrome:148.0-20260505
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
at org.example.testcontainerseleniumbugdemo.BuggyTest.testContainer(BuggyTest.java:22)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
... 2 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
... 3 more
Caused by: com.github.dockerjava.api.exception.BadRequestException: Status 400: {"message":"Duplicate mount point: /dev/shm"}
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:237)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:124)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:37)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33)
at org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:608)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:425)
... 5 more
Additional Information
The problem is most likely located in https://github.com/testcontainers/testcontainers-java/blob/main/modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java#L224 that adds the /dev/shm bind again, not checking that the bind has been already added previously.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java around line 224, where the /dev/shm bind is added. Reproduce the issue with the provided BuggyTest on Linux, then verify that starting the same BrowserWebDriverContainer after stopping it no longer fails with a duplicate mount point error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100