Skip to content

Commit 088e234

Browse files
ArangoDB
1 parent a9e22c9 commit 088e234

File tree

13 files changed

+140
-136
lines changed

13 files changed

+140
-136
lines changed

docs/features/compose.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Create and start a Docker Compose environment:
66

7-
```javascript
7+
```js
88
const { DockerComposeEnvironment } = require("testcontainers");
99

1010
const composeFilePath = "/path/to/build-context";
@@ -15,7 +15,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
1515

1616
You can override by providing [multiple compose files](https://docs.docker.com/compose/extends/#multiple-compose-files):
1717

18-
```javascript
18+
```js
1919
const environment = await new DockerComposeEnvironment(
2020
composeFilePath,
2121
[
@@ -27,14 +27,14 @@ const environment = await new DockerComposeEnvironment(
2727

2828
Provide a list of service names to only start those services:
2929

30-
```javascript
30+
```js
3131
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
3232
.up(["redis-1", "postgres-1"]);
3333
```
3434

3535
### With wait strategy
3636

37-
```javascript
37+
```js
3838
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
3939
.withWaitStrategy("redis-1", Wait.forLogMessage("Ready to accept connections"))
4040
.withWaitStrategy("postgres-1", Wait.forHealthCheck())
@@ -46,7 +46,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
4646
By default Testcontainers uses the "listening ports" wait strategy for all containers. If you'd like to override
4747
the default wait strategy for all services, you can do so:
4848

49-
```javascript
49+
```js
5050
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
5151
.withDefaultWaitStrategy(Wait.forHealthCheck())
5252
.up();
@@ -56,7 +56,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
5656

5757
Testcontainers will automatically pull an image if it doesn't exist. This is configurable:
5858

59-
```javascript
59+
```js
6060
const { DockerComposeEnvironment, PullPolicy } = require("testcontainers");
6161

6262
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
@@ -66,7 +66,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
6666

6767
Create a custom pull policy:
6868

69-
```typescript
69+
```ts
7070
const { GenericContainer, ImagePullPolicy } = require("testcontainers");
7171

7272
class CustomPullPolicy implements ImagePullPolicy {
@@ -82,7 +82,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
8282

8383
### With rebuild
8484

85-
```javascript
85+
```js
8686
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
8787
.withBuild()
8888
.up();
@@ -92,7 +92,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
9292

9393
See [environment file](https://docs.docker.com/compose/environment-variables/#using-the---env-file--option).
9494

95-
```javascript
95+
```js
9696
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
9797
.withEnvironmentFile(".env.custom")
9898
.up();
@@ -102,15 +102,15 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
102102

103103
See [profiles](https://docs.docker.com/compose/profiles/).
104104

105-
```javascript
105+
```js
106106
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
107107
.withProfiles("profile1", "profile2")
108108
.up();
109109
```
110110

111111
### With no recreate
112112

113-
```javascript
113+
```js
114114
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
115115
.withNoRecreate()
116116
.up();
@@ -126,7 +126,7 @@ services:
126126
image: redis:${TAG}
127127
```
128128
129-
```javascript
129+
```js
130130
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
131131
.withEnvironment({ "TAG": "VALUE" })
132132
.up();
@@ -136,7 +136,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
136136

137137
See [project name](https://docs.docker.com/compose/project-name/).
138138

139-
```javascript
139+
```js
140140
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
141141
.withProjectName("test")
142142
.up();
@@ -146,7 +146,7 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
146146

147147
See [docker-compose](https://github.com/PDMLab/docker-compose/) library.
148148

149-
```javascript
149+
```js
150150
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
151151
.withClientOptions({ executable: { standalone: true, executablePath: "/path/to/docker-compose" } })
152152
.up();
@@ -157,21 +157,21 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
157157

158158
Testcontainers by default will not wait until the environment has downed. It will simply issue the down command and return immediately. This is to save time when running tests.
159159

160-
```javascript
160+
```js
161161
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile).up();
162162
await environment.down();
163163
```
164164

165165
If you need to wait for the environment to be downed, you can provide a timeout:
166166

167-
```javascript
167+
```js
168168
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile).up();
169169
await environment.down({ timeout: 10_000 }); // 10 seconds
170170
```
171171

172172
Volumes created by the environment are removed when stopped. This is configurable:
173173

174-
```javascript
174+
```js
175175
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile).up();
176176
await environment.down({ removeVolumes: false });
177177
```
@@ -180,7 +180,7 @@ await environment.down({ removeVolumes: false });
180180

181181
If you have multiple docker-compose environments which share dependencies such as networks, you can stop the environment instead of downing it:
182182

183-
```javascript
183+
```js
184184
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile).up();
185185
await environment.stop();
186186
```
@@ -189,6 +189,6 @@ await environment.stop();
189189

190190
Interact with the containers in your compose environment as you would any other Generic Container. Note that the container name suffix has changed from `_` to `-` between docker-compose v1 and v2 respectively.
191191

192-
```javascript
192+
```js
193193
const container = environment.getContainer("alpine-1");
194194
```

0 commit comments

Comments
 (0)