Skip to content

Commit

Permalink
chore: Add documentation for DependsOn
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathew-Estafanous committed Jan 9, 2024
1 parent 5d1b880 commit f81c84c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/features/common_functional_options.md
Expand Up @@ -68,3 +68,19 @@ If you need an advanced configuration for the container, you can leverage the fo
- `testcontainers.WithEndpointSettingsModifier`

Please read the [Create containers: Advanced Settings](/features/creating_container.md#advanced-settings) documentation for more information.

#### DependsOn Another Container

Sometimes, a container may depend on another container to be ready before it can start itself. For example a web app
container may depend on a running database container it can connect to. Use `DependsOn` in `ContainerRequest`
to list containers that must run before the current one starts. Any container referenced in `DependsOn` will
be started if not already running.

```golang
dbContainer, err := testcontainers.GenericContainer(...)
req = &ContainerRequest{
Image: "myapp:latest",
Name: "myapp",
DependsOn: []Container{dbContainer}, // myapp depends on dbContainer.
}
```

0 comments on commit f81c84c

Please sign in to comment.