Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Start a group of containers with dependencies and shared cleanup

未关闭
#1,565 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker, node.js, typescript
领域
devtools, testing

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

enhancement minor

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 own Promise.all.
  • With Promise.all, if one start() 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 and Startables.deepStart(...) for parallel start.
  • DockerComposeEnvironment covers 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.
主要语言
TypeScript
星标
2.6k
派生
278
平均合并
1 天 11 小时
30 天内合并 PR
60

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

testcontainers/testcontainers-node 的其他 Issue

查看 testcontainers/testcontainers-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。