Official Module

Cockroach Labs
We partner with software vendors to maintain and certify official modules.

Community Module

These modules are maintained by the community, outside of the Testcontainers project.

Description

CockroachDB is an open-source, cloud-native, resilient, distributed SQL database.

Examples

Dependency:
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>cockroachdb</artifactId>
    <version>1.20.0</version>
    <scope>test</scope>
</dependency>
Usage:
var cockroach = new new CockroachContainer(DockerImageName.parse("cockroachdb/cockroach:v22.2.3"));
cockroach.start();
Dependency:
go get github.com/testcontainers/testcontainers-go/modules/cockroachdb
Usage:
cockroachdbContainer, err := cockroachdb.Run(context.Background(), "cockroachdb/cockroach:v22.2.3")
Dependency:
dotnet add package Testcontainers.CockroachDb
Usage:
var cockroachDbContainer = new CockroachDbBuilder()
  .WithImage("cockroachdb/cockroach:latest-v23.1")
  .Build();
await cockroachDbContainer.StartAsync();
Dependency:
npm install @testcontainers/cockroachdb --save-dev
Usage:
const container = await new CockroachDbContainer("cockroachdb/cockroach:v24.3.5").start();
Dependency:
pip install testcontainers[cockroachdb]
Usage:
with CockroachDBContainer('cockroachdb/cockroach:v24.1.1') as crdb:
  engine = sqlalchemy.create_engine(crdb.get_connection_url())
  with engine.begin() as connection:
    result = connection.execute(sqlalchemy.text("select version()"))
    version, = result.fetchone()
Dependency:
cargo add -F clicockroach_db --dev testcontainers-modules
Usage:
testcontainers_modules::cockroach_db::CockroachDb::default().start()