What is Testcontainers?
Testcontainers is an open-source framework that lets your tests start throwaway instances of real dependencies, such as PostgreSQL, MySQL, Kafka, Redis or a browser, in Docker containers. Instead of mocking these services or maintaining a shared test environment, each test run gets a clean, real instance that is created on demand and cleaned up automatically. Testcontainers has libraries for Java, Go, .NET, Node.js, Python, Rust and other languages, and it works anywhere Docker runs, including CI.
Key features
- Real dependencies in tests: run databases, queues, caches and other services as containers.
- Throwaway environments: containers start for the test and are removed afterwards.
- Modules: ready-made modules for popular technologies such as PostgreSQL, Kafka, Redis and more.
- Many languages: libraries for Java, Go, .NET, Node.js, Python, Rust and others.
- Wait strategies: wait until a service is actually ready before tests run.
- Networking: connect containers to each other and to your tests.
- CI-friendly: works in any CI environment that has Docker.
- Local development: can also be used to start dependencies while developing.
Who is it for?
Testcontainers is for backend developers and QA engineers who want reliable integration tests against real services, and for teams tired of flaky shared test environments or mocks that drift from production. Because every developer and CI job gets the same versions of each dependency, tests behave consistently everywhere.
Use cases
- Integration tests against a real PostgreSQL or MySQL database
- Testing Kafka producers and consumers
- Testing caching logic against real Redis
- End-to-end tests with browsers in containers
- Spinning up dependencies for local development
Pricing
The Testcontainers libraries are free and open source. See testcontainers.com for guides and language-specific docs.
What's new and trending
Testcontainers for Node.js v12.2.1 was released on October 13, 2026 (release notes), and Testcontainers for Go v0.44.0 came out on August 7, 2026 (release notes).
Getting started
- Make sure Docker is installed and running.
- Add the Testcontainers library for your language, for example
npm install --save-dev testcontainersfor Node.js. - Start a container in your test, such as a PostgreSQL module.
- Read the container's host and port and connect your code to it.
- Run your tests; containers are cleaned up automatically.
Alternatives
Docker is the container runtime Testcontainers relies on. WireMock and Mock Service Worker mock HTTP APIs instead of running real services, and Playwright, Vitest and Jest are test frameworks you can combine with Testcontainers.
FAQ
Do I need Docker to use Testcontainers? Yes. Testcontainers starts dependencies as Docker containers.
Is Testcontainers free? Yes. The libraries are open source.
Which languages are supported? Java, Go, .NET, Node.js, Python, Rust and others.
Does Testcontainers work in CI? Yes, in any CI environment where Docker is available.
Why not just use mocks? Mocks can drift from real behavior. Testcontainers tests against the real service, which catches more integration bugs.

