Address Compose containers by service name
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker-compose, typescript
- Domain
- devtools, testing-qa
Research direction
Start by reading packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts and started-docker-compose-environment.ts, then trace the compose name parsing entry point in packages/testcontainers/src/docker-runtime/clients/compose/parse-compose-container-name.ts. Check how containers are identified and how wait strategies and getContainer resolve them; done means those APIs accept service names with an optional replica index while retaining container-name support, and the constructor parameter is named for the directory it receives.
Written by the indexing model from the issue text.
Description
What happens
DockerComposeEnvironment identifies containers by container name, not by the service name written in the compose file:
const environment = await new DockerComposeEnvironment(dir, "docker-compose.yml")
.withWaitStrategy("redis-1", Wait.forLogMessage("Ready to accept connections"))
.up();
const redis = environment.getContainer("redis-1");
- The
-1suffix is a Compose naming detail the user has to know. - A service with
container_name:set is keyed by that name instead. - A wait strategy registered under the service name (
"redis") matches nothing.up()now logs a warning for that case, and the docs carry a callout, but the default wait strategy is still what runs. getContainer("redis")throwsCannot get container "redis" as it is not running.
The first constructor parameter is also misnamed: composeFilePath is the directory that contains the compose files, and the docs assign it "/path/to/build-context".
Expected
withWaitStrategyandgetContaineraccept a service name, with an optional replica index, and keep accepting a container name.- The constructor parameter is named for what it is.
Where
packages/testcontainers/src/docker-compose-environment/docker-compose-environment.tspackages/testcontainers/src/docker-compose-environment/started-docker-compose-environment.tspackages/testcontainers/src/container-runtime/clients/compose/parse-compose-container-name.ts
Notes
- Java uses service names throughout:
waitingFor(serviceName, strategy),getServiceHost(serviceName, port),getContainerByServiceName(serviceName), with an optional instance number onwithExposedService. Go hasServiceContainer(ctx, svcName)andWaitForService(name, strategy). - Compose labels each container with
com.docker.compose.serviceandcom.docker.compose.container-number, so resolving a service does not need name parsing. - Related: #647.
Dependencies
- Nothing blocks this. It can start now.
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 290
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 22
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from testcontainers/testcontainers-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
testcontainers/testcontainers-node#1673 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
testcontainers/testcontainers-node#1539 ·
Maintainers usually reply within 4 days
-
Let `Wait.forListeningPorts()` wait on specific portsPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testcontainers/testcontainers-node#1533 ·
Maintainers usually reply within 4 days
-
enhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
testcontainers/testcontainers-node#1531 ·
Maintainers usually reply within 4 days
-
Export the types used in public method signaturesPossibly taken @artbom claimed this 29 days ago. Openenhancement minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-node#1528 ·
Maintainers usually reply within 4 days
All issues in testcontainers/testcontainers-node
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day