mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-06-11 09:50:03 -04:00
* feat: Add docker_compose resource * test: Run docker-compose tests as acc tests * chore(docs): Update documentation * chore(deps): Update gomod * chore: Try out macos runner and go 1.25 * chore: Update goreleaser configuration * chore: Update goreleaser versions and github actions * chore: Bump remaining setup-go action and go version in workflows --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com>
3.1 KiB
3.1 KiB
| page_title | subcategory | description |
|---|---|---|
| Resource docker_compose - terraform-provider-docker | Manages a Docker Compose application using the Docker Compose Go packages. The resource loads one or more Compose files and applies them with the equivalent of docker compose up, then removes them with the equivalent of docker compose down. |
Resource (docker_compose)
Manages a Docker Compose application using the Docker Compose Go packages. The resource loads one or more Compose files and applies them with the equivalent of docker compose up, then removes them with the equivalent of docker compose down.
Example Usage
Basic
The following configuration applies a Compose project from a single Compose file.
resource "docker_compose" "app" {
project_name = "example-compose-app"
config_paths = [
"${path.module}/compose.yaml",
]
}
Profiles and Env Files
The following configuration enables a Compose profile and loads environment variables from an env file before parsing the Compose configuration.
resource "docker_compose" "app" {
project_name = "example-compose-app"
remove_orphans = true
wait = true
wait_timeout = "30s"
profiles = ["frontend"]
env_files = [
"${path.module}/app.env",
]
config_paths = [
"${path.module}/compose.yaml",
"${path.module}/compose.override.yaml",
]
}
Behavior Notes
- This resource uses the Docker Compose Go packages directly and does not shell out to the
docker composeCLI. - The resource is intentionally file-based: Terraform manages one Compose project from one or more Compose files instead of modeling the Compose YAML structure as nested Terraform blocks.
- Apply and update both reconcile the project from the supplied Compose files, while destroy removes the project with the equivalent of
docker compose down.
Schema
Required
config_paths(List of String) One or more Compose file paths, equivalent to repeating the-fflag withdocker compose.
Optional
env_files(List of String) Optional list of env files to load before parsing the Compose configuration. If omitted, Compose uses the default.envbehavior.profiles(List of String) Optional list of Compose profiles to enable.project_directory(String) Optional project directory used as the Compose working directory. If omitted, Compose uses the directory of the first file inconfig_paths.project_name(String) Optional Compose project name. If omitted, Compose derives the project name the same way as the CLI.remove_orphans(Boolean) Iftrue, remove containers for services that are no longer present in the Compose configuration during apply and destroy.wait(Boolean) Iftrue, wait until services reach the running or healthy state before returning from apply.wait_timeout(String) Optional duration forwait, for example30sor2m.
Read-Only
id(String) The Compose project name used as the Terraform resource ID.