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
Use the advanced `NewDockerComposeWith(...)` constructor allowing you to customise the compose execution with options:
61
30
62
31
-`StackIdentifier`: the identifier for the stack, which is used to name the network and containers. If not passed, a random identifier is generated.
63
32
-`WithStackFiles`: specify the Docker Compose stack files to use, as a variadic argument of string paths where the stack files are located.
64
33
-`WithStackReaders`: specify the Docker Compose stack files to use, as a variadic argument of `io.Reader` instances. It will create a temporary file in the temp dir of the given O.S., that will be removed after the `Down` method is called. You can use both `WithComposeStackFiles` and `WithComposeStackReaders` at the same time.
[Get Service Names](../../modules/compose/compose_examples_test.go) inside_block:getServiceNames
40
+
[Get Service Container](../../modules/compose/compose_examples_test.go) inside_block:getServiceContainer
41
+
<!--/codeinclude-->
42
+
66
43
#### Compose Up options
67
44
68
45
-`Recreate`: recreate the containers. If any other value than `api.RecreateNever`, `api.RecreateForce` or `api.RecreateDiverged` is provided, the default value `api.RecreateForce` will be used.
@@ -76,91 +53,26 @@ Use the advanced `NewDockerComposeWith(...)` constructor allowing you to customi
76
53
-`RemoveOrphans`: remove orphaned containers after the stack is stopped.
77
54
-`RemoveVolumes`: remove volumes after the stack is stopped.
To interact with service containers after a stack was started it is possible to get an `*tc.DockerContainer` instance via the `ServiceContainer(...)` function.
115
-
The function takes a **service name** (and a `context.Context`) and returns either a `*tc.DockerContainer` or an `error`.
116
-
This is different to the previous `LocalDockerCompose` API where service containers were accessed via their **container name** e.g. `mysql_1` or `mysql-1` (depending on the version of `docker compose`).
58
+
To interact with service containers after a stack was started it is possible to get a `*testcontainers.DockerContainer` instance via the `ServiceContainer(...)` function.
59
+
The function takes a **service name** (and a `context.Context`) and returns either a `*testcontainers.DockerContainer` or an `error`.
117
60
118
61
Furthermore, there's the convenience function `Services()` to get a list of all services **defined** by the current project.
119
62
Note that not all of them need necessarily be correctly started as the information is based on the given compose files.
120
63
121
64
### Wait strategies
122
65
123
-
Just like with regular test containers you can also apply wait strategies to `docker compose` services.
66
+
Just like with the containers created by _Testcontainers for Go_, you can also apply wait strategies to `docker compose` services.
124
67
The `ComposeStack.WaitForService(...)` function allows you to apply a wait strategy to **a service by name**.
125
68
All wait strategies are executed in parallel to both improve startup performance by not blocking too long and to fail
0 commit comments