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/advanced_options.md
+16
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,8 @@ It is possible to specify an Image Pull Policy to determine at runtime whether a
33
33
34
34
## Customizing the container
35
35
36
+
### Using docker-java
37
+
36
38
It is possible to use the [`docker-java`](https://github.com/docker-java/docker-java) API directly to customize containers before creation. This is useful if there is a need to use advanced Docker features that are not exposed by the Testcontainers API. Any customizations you make using `withCreateContainerCmdModifier` will be applied _on top_ of the container definition that Testcontainers creates, but before it is created.
37
39
38
40
For example, this can be used to change the container hostname:
@@ -53,6 +55,20 @@ For example, this can be used to change the container hostname:
53
55
54
56
For what is possible, consult the [`docker-java CreateContainerCmd` source code](https://github.com/docker-java/docker-java/blob/3.2.1/docker-java-api/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java).
55
57
58
+
### Using CreateContainerCmdModifier
59
+
60
+
Testcontainers provides a `CreateContainerCmdModifier` to customize [`docker-java CreateContainerCmd`](https://github.com/docker-java/docker-java/blob/3.2.1/docker-java-api/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java)
61
+
via Service Provider Interface (SPI) mechanism.
62
+
63
+
<!--codeinclude-->
64
+
[CreateContainerCmd example implementation](../../core/src/test/java/org/testcontainers/custom/TestCreateContainerCmdModifier.java)
65
+
<!--/codeinclude-->
66
+
67
+
The previous implementation should be registered in `META-INF/services/org.testcontainers.core.CreateContainerCmdModifier` file.
68
+
69
+
!!! warning
70
+
`CreateContainerCmdModifier` implementation will apply to all containers created by Testcontainers.
71
+
56
72
## Parallel Container Startup
57
73
58
74
Usually, containers are started sequentially when more than one container is used.
0 commit comments