testcontainers-core
Core component of testcontainers-python.
What it is and what it does
testcontainers-core is the foundation of the testcontainers-python library, enabling developers to use Docker containers as ephemeral test fixtures for integration and functional testing. Instead of managing database instances or other services manually, you define containers declaratively in your test code and they start and stop with your test lifecycle.
The package wraps Docker's API and provides container lifecycle management through Python context managers. It handles resource cleanup automatically and includes ryuk, a sidecar container that ensures dangling test containers are reaped even if tests crash. With only docker and wrapt as runtime dependencies, it has minimal overhead and integrates naturally into test frameworks.
Use it for:
- Spin up a PostgreSQL database for each test run without manual provisioning or teardown.
- Test application code against a real service instance in isolation without affecting other tests.
- Verify database migrations and schema changes in a fresh container for each test suite run.
- Integration test services by launching dependent containers on demand.
- Validate application behavior against specific service versions by pulling different container images per test.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Docker container orchestration for functional and integration testing, allowing tests to spin up isolated service containers on demand without manual setup.
Yes, with conditions. The package is actively maintained and widely used, with no known vulnerabilities. However, it is still at release candidate stage (0.0.1rc1) with no stable release, and its license is unclear in the metadata. Install it for testing workflows if you accept pre-release stability and can verify the license separately; avoid it in production code or strict license-compliance environments until a stable release and clear license terms are published.
Install
testcontainers-core on PyPI
pip
pip install testcontainers-coreuv
uv add testcontainers-corepoetry
poetry add testcontainers-coreInstalling testcontainers-core
Before you install
Low install friction with only two runtime dependencies (docker and wrapt). Actively maintained with recent commits; however, the package is at release candidate stage (0.0.1rc1) and has not had a stable release since its initial 2023-01-06 date, which may warrant caution in production environments.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license terms before adopting this package in a commercial or restricted-license project.
Quickstart
pip install testcontainers-core
from testcontainers.postgres import PostgresContainer
with PostgresContainer("postgres:16") as postgres:
connection_url = postgres.get_connection_url()
Requires Docker daemon to be running and accessible; tests will fail if Docker is not installed or the daemon is not reachable.
Verify before relying
- Whether the package has an official stable release or if 0.0.1rc1 is the current recommended version for production use.
- The actual license under which testcontainers-core is distributed, given the unclear license_treatment in metadata.
- Support scope and compatibility for container runtimes beyond Docker (e.g., Podman).
- Full range of supported container types beyond PostgreSQL mentioned in the description excerpt.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — docker, wrapt |
| Maintenance | actively maintained — 1,316 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 341,414/month — #7,403 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: testcontainers_core-0.0.1rc1-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
testcontainersTestcontainers spins up Docker containers on…
permissive · top 1,000 on PyPI
testcontainers-postgresProvides a PostgreSQL Docker container wrapper…
unclear · top 15,000 on PyPI
pytest-databasesProvides pytest fixtures that spin up isolated…
permissive · top 15,000 on PyPI
pytest-containerA pytest plugin that automates container…
copyleft · top 15,000 on PyPI
tox-dockerA tox plugin that manages Docker container…
permissive · top 15,000 on PyPI
prefect-dockerProvides Docker task execution and container…
permissive · top 5,000 on PyPI
pytest-mock-resourcesProvides pytest fixtures that spin up real…
permissive · top 15,000 on PyPI
pytest-docker-toolsProvides pytest fixture factories for…
permissive · top 5,000 on PyPI
dockerA Python library that lets you programmatically…
permissive · top 1,000 on PyPI
returnsProvides functional programming…
permissive · top 5,000 on PyPI