You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/containers.md
+37-29Lines changed: 37 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,14 @@ const container = await new GenericContainer("alpine")
68
68
.start();
69
69
```
70
70
71
+
### With a platform
72
+
73
+
```javascript
74
+
constcontainer=awaitnewGenericContainer("alpine")
75
+
.withPlatform("linux/arm64") // similar to `--platform linux/arm64`
76
+
.start();
77
+
```
78
+
71
79
### With bind mounts
72
80
73
81
**Not recommended.**
@@ -76,9 +84,9 @@ Bind mounts are not portable. They do not work with Docker in Docker or in cases
76
84
77
85
```javascript
78
86
constcontainer=awaitnewGenericContainer("alpine")
79
-
.withBindMounts([{
80
-
source:"/local/file.txt",
81
-
target:"/remote/file.txt"
87
+
.withBindMounts([{
88
+
source:"/local/file.txt",
89
+
target:"/remote/file.txt"
82
90
}, {
83
91
source:"/local/dir",
84
92
target:"/remote/dir",
@@ -97,7 +105,7 @@ const container = await new GenericContainer("alpine")
97
105
98
106
### With a name
99
107
100
-
**Not recommended.**
108
+
**Not recommended.**
101
109
102
110
If a container with the same name already exists, Docker will raise a conflict. If you are specifying a name to enable container to container communication, look into creating a network and using [network aliases](../networking#network-aliases).
103
111
@@ -113,15 +121,15 @@ Copy files/directories or content to a container before it starts:
@@ -151,8 +159,8 @@ An optional `mode` can be specified in octal for setting file permissions:
151
159
152
160
```javascript
153
161
constcontainer=awaitnewGenericContainer("alpine")
154
-
.withCopyFilesToContainer([{
155
-
source:"/local/file.txt",
162
+
.withCopyFilesToContainer([{
163
+
source:"/local/file.txt",
156
164
target:"/remote/file1.txt",
157
165
mode:parseInt("0644", 8)
158
166
}])
@@ -161,7 +169,7 @@ const container = await new GenericContainer("alpine")
161
169
target:"/some/nested/remotedir",
162
170
mode:parseInt("0644", 8)
163
171
}])
164
-
.withCopyContentToContainer([{
172
+
.withCopyContentToContainer([{
165
173
content:"hello world",
166
174
target:"/remote/file2.txt",
167
175
mode:parseInt("0644", 8)
@@ -258,10 +266,10 @@ const container = await new GenericContainer("alpine")
258
266
259
267
```javascript
260
268
constcontainer=awaitnewGenericContainer("aline")
261
-
.withUlimits({
262
-
memlock: {
263
-
hard:-1,
264
-
soft:-1
269
+
.withUlimits({
270
+
memlock: {
271
+
hard:-1,
272
+
soft:-1
265
273
}
266
274
})
267
275
.start();
@@ -339,7 +347,7 @@ await container.restart();
339
347
340
348
## Reusing a container
341
349
342
-
Enabling container re-use means that Testcontainers will not start a new container if a Testcontainers managed container with the same configuration is already running.
350
+
Enabling container re-use means that Testcontainers will not start a new container if a Testcontainers managed container with the same configuration is already running.
343
351
344
352
This is useful for example if you want to share a container across tests without global set up.
0 commit comments