Skip to content

Document that container_name is not supported in Compose files - #12177

Open
sharatthk wants to merge 1 commit into
testcontainers:mainfrom
sharatthk:docs/compose-container-name-limitation
Open

sharatthk wants to merge 1 commit into
testcontainers:mainfrom
sharatthk:docs/compose-container-name-limitation

Conversation

@sharatthk

@sharatthk sharatthk commented Nov 18, 2026 •

Copy link
Copy Markdown

What

Starting a ComposeContainer or DockerComposeContainer with a Compose file that sets container_name fails with an IllegalStateException, but the Docker Compose docs don't mention this. Users only find out at runtime, as reported in #2472.

This adds a note to docs/modules/docker_compose.md explaining that container_name is not supported, why (each environment runs under a random project name so several can run side by side), and what to do instead.

Docs only, no code change. Refs #2472 (the issue also asks for actual support, so it stays open).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added guidance that setting container_name on a Docker Compose service can cause Compose startup to fail in tests. The documentation recommends omitting it and referring to containers by their service names instead.

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 testcontainers#2472
@sharatthk
sharatthk requested a review from a team as a code owner November 18, 2026 06:06
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Docker Compose module documentation adds a note about startup failures when a service sets container_name. It explains the random project name and advises removing the setting in tests and using service names.

Changes: Docker Compose documentation

Layer / File(s) Summary
Document container_name behavior
docs/modules/docker_compose.md
The Example section describes the IllegalStateException startup failure and recommends removing container_name in tests and referring to containers by service name.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Suggested labels: type/docs

Suggested reviewers: eddumelendez

Merge Risk: Minimal · up to 72dec

This documentation-only change clarifies that Compose files setting container_name are not supported and advises using service names instead. It carries no runtime risk and is ready to merge.

Pre-merge checks: Passed 7

Check name Status Explanation
Title check Passed The title names the main change: it documents that container_name is not supported in Compose files. The raw summary and objectives confirm the PR only adds a docs note about this limitation. The titl…
Description check Passed The description covers what the change does, why it is needed, and the related issue (#2472). It explains the cause (random project name per environment) and the alternative (use service names). It fo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
New Module Registration Passed The check applies only when the PR adds a new directory under modules/. The PR's complete changed-file inventory (git diff --name-status between the review base and head) is a single modified file: do…
Public Api Compatibility Passed The check is inapplicable to this pull request. The changed-file inventory for refs/coderabbit/pre-merge-check/base..head contains a single modified file, docs/modules/docker_compose.md. The diff rest…
Tests For Behaviour Changes Passed The check fails only when a PR changes behaviour in src/main/java without a matching test under src/test. It exempts documentation-only changes. The changed-file inventory for the reviewed range (refs…
Full details: Title check

Explanation

The title names the main change: it documents that container_name is not supported in Compose files. The raw summary and objectives confirm the PR only adds a docs note about this limitation. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description covers what the change does, why it is needed, and the related issue (#2472). It explains the cause (random project name per environment) and the alternative (use service names). It follows the template's intent of describing the change and its context. The template's checklist items (new module registration, checkstyle/spotless run) do not apply to a docs-only change, so they are not required here.

Full details: New Module Registration

Explanation

The check applies only when the PR adds a new directory under modules/. The PR's complete changed-file inventory (git diff --name-status between the review base and head) is a single modified file: docs/modules/docker_compose.md (M). No file is added under modules/, and no new module directory is created. The check is therefore inapplicable and passes. The primary PR is #12177 by sharatthk, targeting main; the author identity does not affect this result.

Full details: Public Api Compatibility

Explanation

The check is inapplicable to this pull request. The changed-file inventory for refs/coderabbit/pre-merge-check/base..head contains a single modified file, docs/modules/docker_compose.md. The diff restricted to src/main/java is empty, so no public or protected class, method, constructor or field under src/main/java was removed, renamed, or had its signature, return type or visibility changed. The PR is documentation only (+6/-0), matching the PR description and summary. Provider-reported PR #12177 (testcontainers/testcontainers-java, author sharatthk) does not alter the public API. The check therefore passes.

Full details: Tests For Behaviour Changes

Explanation

The check fails only when a PR changes behaviour in src/main/java without a matching test under src/test. It exempts documentation-only changes. The changed-file inventory for the reviewed range (refs/coderabbit/pre-merge-check/base to head) contains a single file: M docs/modules/docker_compose.md. No file under src/main/java changed, so no behaviour change exists to require a test. The PR description also states "Docs only, no code change." The check is inapplicable and passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e16dca9 and 72dec2b.

Files selected for processing: 1

  • docs/modules/docker_compose.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant