diff --git a/docs/features/containers.md b/docs/features/containers.md index 288fe3700..16afa5f38 100644 --- a/docs/features/containers.md +++ b/docs/features/containers.md @@ -355,7 +355,7 @@ const container = await new GenericContainer("alpine") .withAutoRemove(false) .start(); -await container.stop() +await container.stop(); ``` The value specified to `.withAutoRemove()` can be overridden by `.stop()`: @@ -365,9 +365,12 @@ const container = await new GenericContainer("alpine") .withAutoRemove(false) .start(); -await container.stop({ remove: true }) // The container is stopped *AND* removed +await container.stop({ remove: true }); // The container is stopped *AND* removed ``` +Keep in mind that disabling ryuk (set `TESTCONTAINERS_RYUK_DISABLED` to `true`) **and** disabling automatic removal of containers will make containers persist after you're done working with them. + + Volumes created by the container are removed when stopped. This is configurable: ```javascript @@ -425,6 +428,22 @@ const container2 = await new GenericContainer("alpine") expect(container1.getId()).toBe(container2.getId()); ``` +You can also re-use stopped but not removed containers. + +```javascript +const container1 = await new GenericContainer("alpine") + .withReuse() + .withAutoRemove(false) + .start(); +await container1.stop(); + +const container2 = await new GenericContainer("alpine") + .withReuse() + .start(); + +expect(container1.getId()).toBe(container2.getId()); +``` + Container re-use can be enabled or disabled globally by setting the `TESTCONTAINERS_REUSE_ENABLE` environment variable to `true` or `false`. If this environment variable is not declared, the feature is enabled by default. diff --git a/docs/features/images.md b/docs/features/images.md index f5cd6d434..fc4083b82 100644 --- a/docs/features/images.md +++ b/docs/features/images.md @@ -91,6 +91,15 @@ const container = await GenericContainer .build(); ``` +### With platform + +```javascript +const container = await GenericContainer + .fromDockerfile("/path/to/build-context") + .withPlatform("linux/amd64") + .build(); +``` + ## Image name substitution Testcontainers supports automatic substitution of Docker image names. diff --git a/docs/index.md b/docs/index.md index 8bff16d63..d0ecd9390 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,10 +6,14 @@ Go .NET Node.js + Clojure + Elixir + Haskell Python - Rust - Haskell Ruby + Rust + PHP + Scala ## About @@ -22,7 +26,7 @@ See [LICENSE](https://raw.githubusercontent.com/testcontainers/testcontainers-no ## Copyright -Copyright (c) 2018 - 2023 Cristian Greco and other authors. +Copyright (c) 2018 - 2025 Cristian Greco and other authors. See [contributors](https://github.com/testcontainers/testcontainers-node/graphs/contributors/) for contributors. diff --git a/docs/site/language-logos/clojure.svg b/docs/site/language-logos/clojure.svg new file mode 100644 index 000000000..506db3b7d --- /dev/null +++ b/docs/site/language-logos/clojure.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docs/site/language-logos/elixir.svg b/docs/site/language-logos/elixir.svg new file mode 100644 index 000000000..532746a46 --- /dev/null +++ b/docs/site/language-logos/elixir.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/site/language-logos/php.svg b/docs/site/language-logos/php.svg new file mode 100644 index 000000000..939f1ec40 --- /dev/null +++ b/docs/site/language-logos/php.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/docs/site/language-logos/scala.svg b/docs/site/language-logos/scala.svg new file mode 100644 index 000000000..23decc05f --- /dev/null +++ b/docs/site/language-logos/scala.svg @@ -0,0 +1,26 @@ + + + + + Scala + The Scala Logo + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/testcontainers/src/generic-container/generic-container-reuse.test.ts b/packages/testcontainers/src/generic-container/generic-container-reuse.test.ts index 785d92733..b54f521d7 100644 --- a/packages/testcontainers/src/generic-container/generic-container-reuse.test.ts +++ b/packages/testcontainers/src/generic-container/generic-container-reuse.test.ts @@ -129,6 +129,27 @@ describe("GenericContainer reuse", { timeout: 180_000 }, () => { await container2.stop(); }); + it("should reuse stopped container, if configured withAutoRemove(false)", async () => { + const name = `will_stop_and_reuse_again_${randomUuid()}`; + const container1 = await new GenericContainer("cristianrgreco/testcontainer:1.1.14") + .withName(name) + .withExposedPorts(8080) + .withReuse() + .withAutoRemove(false) + .start(); + await container1.stop({ timeout: 10000 }); + + const container2 = await new GenericContainer("cristianrgreco/testcontainer:1.1.14") + .withName(name) + .withExposedPorts(8080) + .withReuse() + .start(); + await checkContainerIsHealthy(container2); + + expect(container1.getId()).toBe(container2.getId()); + await container2.stop({ remove: true }); + }); + it("should reuse container when an existing reusable container has stopped but not removed", async () => { const name = `there_can_only_be_one_${randomUuid()}`; const container1 = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")