From 72dec2b703afe55482a4850c7489d82d544b8cda Mon Sep 17 00:00:00 2001 From: sharath k Date: Wed, 18 Nov 2026 00:06:21 -0600 Subject: [PATCH] Document that container_name is not supported in Compose files Testcontainers rejects Compose files that set container_name, but the docs did not mention it. Add a note explaining why and what to do. Refs #2472 --- docs/modules/docker_compose.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/modules/docker_compose.md b/docs/modules/docker_compose.md index 3d3d7a510c2..befa9e99063 100644 --- a/docs/modules/docker_compose.md +++ b/docs/modules/docker_compose.md @@ -23,6 +23,12 @@ should be sufficient to launch any number of services required by our tests: !!! note Make sure the service names use a `-` rather than `_` as separator. +!!! note "`container_name` is not supported" + Testcontainers starts each Compose environment under a random project name, so that several environments can run + side by side without clashing. A fixed `container_name` would defeat this, so starting a Compose file that sets + `container_name` on any service fails with an `IllegalStateException`. Remove `container_name` from the file used in + tests and refer to the containers by their service names instead. + In this example, Docker Compose file should have content such as: ```yaml services: