Start a group of containers with dependencies and shared cleanup
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- docker, node.js, typescript
Research direction
Read the existing GenericContainer and Network implementations under packages/testcontainers/src, then inspect how container startup and cleanup are handled. Design the group API from the issue’s sketch, including dependency ordering, parallel starts, shared network aliases, and stopping containers if a start fails; done means the group can start and dispose of a set of containers as described.
Written by the indexing model from the issue text.
Description
What happens
A test that needs several containers wires them up by hand:
const network = await new Network().start();
const db = await new PostgreSqlContainer(dbImage).withNetwork(network).withNetworkAliases("db").start();
const app = await new GenericContainer(appImage)
.withNetwork(network)
.withEnvironment({ DATABASE_URL: "postgres://test:test@db:5432/test" })
.withExposedPorts(8080)
.start();
// ...
await app.stop();
await db.stop();
await network.stop();
- Start order is whatever order the
awaits are written in. Independent containers start one after another unless the test adds its ownPromise.all. - With
Promise.all, if onestart()rejects the others keep running until Ryuk removes them at process exit. - Cleanup is one call per container, in the right order.
Expected
A way to declare a set of containers, their dependencies and a shared network, start them as a unit and dispose of them as a unit:
await using group = await new ContainerGroup()
.with("db", new PostgreSqlContainer(dbImage))
.with("app", new GenericContainer(appImage).withExposedPorts(8080), { dependsOn: ["db"] })
.start();
const app = group.get("app");
- Containers without a dependency between them start in parallel.
- Each name becomes a network alias on a network the group owns.
- If any container fails to start, the ones already started are stopped.
Where
New code in packages/testcontainers/src, built on GenericContainer and Network.
Notes
- Java has
dependsOn(Startable...)on containers andStartables.deepStart(...)for parallel start. DockerComposeEnvironmentcovers this when the setup lives in a compose file. This is for setups defined in code, including module containers.- The API shape above is a sketch.
Dependencies
- Nothing blocks this. It can start now.
- Coordinate with #1536: a group puts its containers on a network with aliases.
- Coordinate with #1520: a group starts builders it was handed, so
start()must not change them.
- 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