--- id: testcontainers-postgres version: "0.0.1rc1" license: unclear license_treatment: unclear maintenance: active --- # testcontainers-postgres — PostgreSQL component of testcontainers-python. License: unclear · Maintenance: active · Downloads: 84.2K/mo ## What it is and what it does testcontainers-postgres wraps PostgreSQL in a Docker container and exposes it for use in tests. It is a component of the larger testcontainers-python framework, which facilitates functional and integration testing by spinning up ephemeral service containers on demand. The package depends on testcontainers-core (which handles Docker lifecycle and cleanup), sqlalchemy (for connection URL generation), and psycopg2-binary (the PostgreSQL driver). You use it by instantiating a PostgresContainer with a Docker image tag, entering its context manager, and retrieving a sqlalchemy-compatible connection URL—the container starts automatically and tears down when the context exits. The package is designed to eliminate the need for pre-configured test databases or external services. Configuration is available via environment variables (e.g., TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE, TESTCONTAINERS_RYUK_DISABLED) or runtime settings, allowing control over Docker socket paths, cleanup behavior, and container privileges. Use it for: - Write integration tests that need a real PostgreSQL database without managing containers manually. - Run CI/CD pipelines that spin up isolated test databases per test suite without external dependencies. - Test database migrations and schema changes against a fresh PostgreSQL instance each run. - Develop multi-service tests where PostgreSQL is one of several containerized services. - Prototype applications that depend on PostgreSQL without installing it locally. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a PostgreSQL Docker container wrapper for integration and functional testing, automatically managing container lifecycle and connection details. Yes, if you use Docker for testing and need PostgreSQL containers. The install friction is low, maintenance is active, and there are no known vulnerabilities. However, the package is at 0.0.1rc1—clarify whether this is stable or abandoned before committing to production CI. Also verify the license before use in proprietary projects, as it is currently undeclared. ## Install pip install testcontainers-postgres uv add testcontainers-postgres poetry add testcontainers-postgres ## Installing testcontainers-postgres Before you install: Low install friction with three straightforward runtime dependencies. The package is actively maintained with recent commits. License in practice: License treatment is unclear; the package metadata contains no explicit license declaration. Verify the actual license before using in proprietary or restricted contexts. Quickstart: from testcontainers.postgres import PostgresContainer import sqlalchemy with PostgresContainer("postgres:16") as postgres: engine = sqlalchemy.create_engine(postgres.get_connection_url()) with engine.begin() as connection: result = connection.execute(sqlalchemy.text("select version()")) version, = result.fetchone() Requires Docker to be running and accessible; testcontainers-core manages container lifecycle via Docker socket (configurable via TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE). Verify before relying: - Why the package remains at 0.0.1rc1 despite active maintenance—is this intentional or a pre-release that should have graduated? - Whether the unclear license is documented elsewhere (e.g., in the repository root or GitHub). - Compatibility and feature parity with the parent testcontainers-python project's current state. ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 84.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags postgres docker testing, integration test database, testcontainers postgres, ephemeral postgres container, functional testing postgresql, docker-based test database, containerized postgres for tests, docker-testing, integration-tests, postgres [View on SkillFed](https://skillfed.io/packages/testcontainers-postgres) · [View on PyPI](https://pypi.org/project/testcontainers-postgres/)