testcontainers/testcontainers-java · error · UnsupportedOperationException
Your docker daemon is running the "lxc" driver, which…
Error message
Your docker daemon is running the "lxc" driver, which doesn't support "docker exec".
What it means
execInContainer requires the Docker daemon's exec capability. TestEnvironment.dockerExecutionDriverSupportsExec() returns false when the daemon uses the legacy lxc execution driver, so the method throws UnsupportedOperationException before attempting exec.
Solutions
- Upgrade the Docker daemon / CI image to a version using libcontainer (native exec driver)
- Change the daemon's exec driver configuration away from lxc
- Replace execInContainer with copyFileToContainer of an entrypoint script if the environment cannot be changed
- Run tests on a different executor that provides a modern Docker daemon
Defensive patterns
Strategy: validation
Validate before calling
if (!TestEnvironment.dockerExecutionDriverSupportsExec()) { throw new AssumptionViolatedException("docker exec unsupported (lxc driver); skipping exec-based tests"); } Try / catch
try { container.execInContainer("cmd"); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("lxc")) { throw new AssumptionViolatedException("environment lacks docker exec support"); } throw e; } Prevention
- Use CI images with modern Docker (libcontainer/native exec driver)
- Check TestEnvironment.dockerExecutionDriverSupportsExec() in test setup and skip gracefully
- Avoid legacy lxc-based runners for integration tests
When it happens
Trigger: Calling execInContainer(...) (directly or via container.execInContainer) against an old Docker daemon configured with the lxc execution driver, as historically seen on CircleCI.
Common situations: Legacy CI environments (old CircleCI images), Docker < 1.10 with lxc as the default exec driver, custom daemon configs with --exec-driver=lxc.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/c6985414c9e43466.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/testcontainers/containers/ExecInContainerPattern.java:190
* driver. At the time of writing, CircleCI was using this driver.
* @param dockerClient the {@link DockerClient}
* @param containerInfo the container info
* @param outputCharset the character set used to interpret the output.
* @param execConfig the exec configuration
* @return the result of execution
* @throws IOException if there's an issue communicating with Docker
* @throws InterruptedException if the thread waiting for the response is interrupted
* @throws UnsupportedOperationException if the docker daemon you're connecting to doesn't support "exec".
*/
public Container.ExecResult execInContainer(
DockerClient dockerClient,
InspectContainerResponse containerInfo,
Charset outputCharset,
ExecConfig execConfig
) throws UnsupportedOperationException, IOException, InterruptedException {
if (!TestEnvironment.dockerExecutionDriverSupportsExec()) {
// at time of writing, this is the expected result in CircleCI.
throw new UnsupportedOperationException(
"Your docker daemon is running the \"lxc\" driver, which doesn't support \"docker exec\"."
);
}
if (!isRunning(containerInfo)) {
throw new IllegalStateException("execInContainer can only be used while the Container is running");
}
String containerId = containerInfo.getId();
String containerName = containerInfo.getName();
String[] command = execConfig.getCommand();
log.debug("{}: Running \"exec\" command: {}", containerName, String.join(" ", command));
final ExecCreateCmd execCreateCmd = dockerClient
.execCreateCmd(containerId)
.withAttachStdout(true)
.withAttachStderr(true)
.withCmd(command);View on GitHub (pinned to 8e549514e3)