Skip to content

Commit

Permalink
Export container runtime (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianrgreco authored Nov 23, 2023
1 parent ec59ed8 commit c1953f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
42 changes: 42 additions & 0 deletions docs/features/advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Advanced

## Container Runtime Client

Testcontainers configures an underlying container runtime to perform its tasks. This runtime works automatically with several providers like Docker, Podman, Colima, Rancher Desktop and Testcontainers Desktop. There are too many usage examples to list here, but here are some common examples:

### Fetch container runtime information

```js
import { getContainerRuntimeClient } from "testcontainers";

const containerRuntimeClient = await getContainerRuntimeClient();

console.log(containerRuntimeClient.info);
```

### Pulling an image

```js
import { ImageName } from "testcontainers";

await containerRuntimeClient.image.pull(ImageName.fromString("alpine:3.12"))
```

### Starting a container

```js
const container = await containerRuntimeClient.container.create({ ... });
await containerRuntimeClient.container.start(container);
```

### Starting a Docker Compose environment

```js
const environment = await containerRuntimeClient.compose.up({ ... })
```

### Starting a network

```js
const network = await containerRuntimeClient.network.create({ ... })
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ nav:
- Networking: features/networking.md
- Compose: features/compose.md
- Wait strategies: features/wait-strategies.md
- Advanced: features/advanced.md
- Modules:
- ArangoDB: modules/arangodb.md
- Elasticsearch: modules/elasticsearch.md
Expand Down
4 changes: 2 additions & 2 deletions packages/testcontainers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {
export { GenericContainer } from "./generic-container/generic-container";
export { GenericContainerBuilder, BuildOptions } from "./generic-container/generic-container-builder";
export { TestContainers } from "./test-containers";
export { ContainerRuntimeClient, getContainerRuntimeClient, ImageName } from "./container-runtime";
export { Uuid, RandomUuid, log } from "./common";

export { DockerComposeEnvironment } from "./docker-compose-environment/docker-compose-environment";
export { StartedDockerComposeEnvironment } from "./docker-compose-environment/started-docker-compose-environment";
Expand All @@ -23,5 +25,3 @@ export { InspectResult, Content, ExecResult } from "./types";

export { AbstractStartedContainer } from "./generic-container/abstract-started-container";
export { AbstractStoppedContainer } from "./generic-container/abstract-stopped-container";

export { Uuid, RandomUuid, log } from "./common";

0 comments on commit c1953f5

Please sign in to comment.