docker-compose
This module provides Docker Compose operations with chainable configurationfor registry authentication, environment variables, and deployment management.
Example usage:
dagger call -m containers/docker-compose \
with-context --host 172.16.24.97 --user admin --ssh-key env:SSH_KEY \
with-registry --host registry.example.com --username env:USER --password env:PASS \
with-secret --key DB_PASSWORD --value env:DB_PASSWORD \
with-variable --key IMAGE_TAG --value v1.0.0 \
deploy --source . --compose-path docker/docker-compose.yml --project-name myapp
Installation
dagger install dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679Entrypoint
Return Type
DockerCompose ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
func (m *MyModule) Example() *dagger.DockerCompose {
return dag.
DockerCompose()
}@function
def example() -> dagger.DockerCompose:
return (
dag.docker_compose()
)@func()
example(): DockerCompose {
return dag
.dockerCompose()
}Types
DockerCompose 🔗
DockerCompose module for managing Docker Compose deployments
registryHost() 🔗
Registry authentication configuration
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
registry-hostfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
DockerCompose().
RegistryHost(ctx)
}@function
async def example() -> str:
return await (
dag.docker_compose()
.registry_host()
)@func()
async example(): Promise<string> {
return dag
.dockerCompose()
.registryHost()
}registryUsername() 🔗
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
registry-usernamefunc (m *MyModule) Example(ctx context.Context) string {
return dag.
DockerCompose().
RegistryUsername(ctx)
}@function
async def example() -> str:
return await (
dag.docker_compose()
.registry_username()
)@func()
async example(): Promise<string> {
return dag
.dockerCompose()
.registryUsername()
}registryPassword() 🔗
Return Type
Secret ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
registry-passwordfunc (m *MyModule) Example() *dagger.Secret {
return dag.
DockerCompose().
RegistryPassword()
}@function
def example() -> dagger.Secret:
return (
dag.docker_compose()
.registry_password()
)@func()
example(): Secret {
return dag
.dockerCompose()
.registryPassword()
}variables() 🔗
Environment variables to inject
Return Type
[DockerComposeVariable ! ] ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
variablesfunc (m *MyModule) Example() []*dagger.DockerComposeVariable {
return dag.
DockerCompose().
Variables()
}@function
def example() -> List[dagger.DockerComposeVariable]:
return (
dag.docker_compose()
.variables()
)@func()
example(): DockerComposeVariable[] {
return dag
.dockerCompose()
.variables()
}sshhost() 🔗
SSH Context configuration for remote deployment
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
sshhostfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
DockerCompose().
Sshhost(ctx)
}@function
async def example() -> str:
return await (
dag.docker_compose()
.sshhost()
)@func()
async example(): Promise<string> {
return dag
.dockerCompose()
.sshhost()
}sshuser() 🔗
Return Type
String ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
sshuserfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
DockerCompose().
Sshuser(ctx)
}@function
async def example() -> str:
return await (
dag.docker_compose()
.sshuser()
)@func()
async example(): Promise<string> {
return dag
.dockerCompose()
.sshuser()
}sshport() 🔗
Return Type
Integer ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
sshportfunc (m *MyModule) Example(ctx context.Context) int {
return dag.
DockerCompose().
Sshport(ctx)
}@function
async def example() -> int:
return await (
dag.docker_compose()
.sshport()
)@func()
async example(): Promise<number> {
return dag
.dockerCompose()
.sshport()
}sshkey() 🔗
Return Type
Secret ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
sshkeyfunc (m *MyModule) Example() *dagger.Secret {
return dag.
DockerCompose().
Sshkey()
}@function
def example() -> dagger.Secret:
return (
dag.docker_compose()
.sshkey()
)@func()
example(): Secret {
return dag
.dockerCompose()
.sshkey()
}envFile() 🔗
Environment file
Return Type
File ! Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
env-filefunc (m *MyModule) Example() *dagger.File {
return dag.
DockerCompose().
EnvFile()
}@function
def example() -> dagger.File:
return (
dag.docker_compose()
.env_file()
)@func()
example(): File {
return dag
.dockerCompose()
.envFile()
}config() 🔗
Parse, resolve and render compose file(s) in canonical format
This function shows the final compose config file.
Parameters: - source: Directory containing the docker-compose.yml file - composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files - projectName: Docker Compose project name (optional, uses directory name if not set)
Example:
dagger call config \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--project-name chat
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| projectName | String | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
config --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
DockerCompose().
Config(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.docker_compose()
.config(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.dockerCompose()
.config(source)
}deploy() 🔗
Deploy deploys the Docker Compose stack
This function performs: 1. Pull and start containers with –pull always –force-recreate 2. Display container status
The –pull always flag ensures images are always re-downloaded from registry, bypassing local cache. This guarantees “latest” tags get the actual latest version.
Parameters: - source: Directory containing the docker-compose.yml file - composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files - projectName: Docker Compose project name (optional, uses directory name if not set)
Example:
dagger call deploy \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--project-name chat
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| projectName | String | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
deploy --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
DockerCompose().
Deploy(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.docker_compose()
.deploy(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.dockerCompose()
.deploy(source)
}down() 🔗
Down stops and removes Docker Compose containers
This function stops all containers and removes them, networks, and volumes created by the Docker Compose stack.
Parameters: - source: Directory containing the docker-compose.yml file - composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files - projectName: Docker Compose project name (optional, uses directory name if not set)
Example:
dagger call down \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--project-name chat
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| projectName | String | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
down --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
DockerCompose().
Down(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.docker_compose()
.down(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.dockerCompose()
.down(source)
}logs() 🔗
Logs retrieves logs from Docker Compose containers
This function fetches the logs from all containers in the Docker Compose stack.
Parameters: - source: Directory containing the docker-compose.yml file - composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files - tail: Number of lines to show from the end of logs (default: 100) - projectName: Docker Compose project name (optional, uses directory name if not set)
Example:
dagger call logs \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--tail 50 \
--project-name chat
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| tail | Integer | 100 | No description provided |
| projectName | String | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
logs --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
DockerCompose().
Logs(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.docker_compose()
.logs(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.dockerCompose()
.logs(source)
}run() 🔗
Run executes a one-shot Compose service via docker compose run --rm,
optionally activating one or more profiles. Designed for bootstrap/init
services gated by profiles: in docker-compose.yml (e.g. schema migrations).
Equivalent to:
docker compose -f <compose> [-p <project>] [--profile <p1> --profile <p2>...] \
run --rm [-e KEY=VAL...] <service> [arg...]
The --rm flag ensures the container is removed after exit; combined with
restart: "no" in compose, this is a clean one-shot semantics.
Parameters:
- source: Directory containing the docker-compose.yml file
- service: Compose service name to run (must exist in compose file)
- composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files
- projectName: Docker Compose project name (optional, uses directory name if not set)
- profiles: Compose profiles to activate (e.g. [“init”]). Repeated --profile flags.
- args: Optional extra arguments appended after the service name (overrides compose command:)
Example:
dagger call \
with-context --host X --user Y --ssh-key env:KEY \
with-secret --key DB_PASSWORD --value env:DB_PASSWORD \
run \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--project-name myapp \
--profiles init \
--service init
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| service | String ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| projectName | String | - | No description provided |
| profiles | [String ! ] | - | No description provided |
| args | [String ! ] | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
run --source DIR_PATH --service stringfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, service string) string {
return dag.
DockerCompose().
Run(ctx, source, service)
}@function
async def example(source: dagger.Directory, service: str) -> str:
return await (
dag.docker_compose()
.run(source, service)
)@func()
async example(source: Directory, service: string): Promise<string> {
return dag
.dockerCompose()
.run(source, service)
}status() 🔗
Status displays the status of Docker Compose containers
This function shows the current state of all containers in the Docker Compose stack, including their names, status, ports, and health status.
Parameters: - source: Directory containing the docker-compose.yml file - composePath: Path to docker-compose.yml relative to source (default: “docker-compose.yml”). Possibility to repete to provide multiple compose files - projectName: Docker Compose project name (optional, uses directory name if not set)
Example:
dagger call status \
--source . \
--compose-path docker/docker-compose.yml \
--compose-path docker/docker-compose.prod.yml \
--project-name chat
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
| composePath | [String ! ] | ["docker-compose.yml"] | No description provided |
| projectName | String | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
status --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
DockerCompose().
Status(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.docker_compose()
.status(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.dockerCompose()
.status(source)
}withContext() 🔗
WithContext configures SSH-based remote Docker context for deployment
This enables deployment to remote Docker hosts via SSH instead of local socket. When configured, all Docker commands will be executed on the remote host.
Parameters: - host: Remote host IP address or hostname - user: SSH username for authentication - port: SSH port (default: 22) - sshKey: SSH private key for authentication
Example:
dagger call with-context \
--host 172.16.24.97 \
--user admincd24 \
--ssh-key env:SSH_PRIVATE_KEY \
deploy --source . --project-name myapp
Return Type
DockerCompose !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| host | String ! | - | No description provided |
| user | String ! | - | No description provided |
| port | Integer | 22 | No description provided |
| sshKey | Secret ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
with-context --host string --user string --ssh-key env:MYSECRETfunc (m *MyModule) Example(host string, user string, sshKey *dagger.Secret) *dagger.DockerCompose {
return dag.
DockerCompose().
WithContext(host, user, sshKey)
}@function
def example(host: str, user: str, ssh_key: dagger.Secret) -> dagger.DockerCompose:
return (
dag.docker_compose()
.with_context(host, user, ssh_key)
)@func()
example(host: string, user: string, sshKey: Secret): DockerCompose {
return dag
.dockerCompose()
.withContext(host, user, sshKey)
}withEnvFile() 🔗
WithEnvFile mounts an environment file for Docker Compose
The file will be mounted as .env in the workspace directory, making it available to docker-compose during deployment.
Parameters: - envFile: The .env file to mount
Example:
dagger call with-env-file --env-file .env.production \
deploy --source . --project-name myapp
Return Type
DockerCompose !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| envFile | File ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
with-env-file --env-file file:pathfunc (m *MyModule) Example(envFile *dagger.File) *dagger.DockerCompose {
return dag.
DockerCompose().
WithEnvFile(envFile)
}@function
def example(env_file: dagger.File) -> dagger.DockerCompose:
return (
dag.docker_compose()
.with_env_file(env_file)
)@func()
example(envFile: File): DockerCompose {
return dag
.dockerCompose()
.withEnvFile(envFile)
}withRegistry() 🔗
WithRegistry configures Docker registry authentication
This allows pulling from private registries before deploying
Parameters: - host: Registry hostname (e.g., “registry.example.com”, “ghcr.io”) - username: Registry username - password: Registry password
Example:
dagger call with-registry \
--host ghcr.io \
--username env:GITHUB_USER \
--password env:GITHUB_TOKEN
Return Type
DockerCompose !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| host | String ! | - | No description provided |
| username | String ! | - | No description provided |
| password | Secret ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
with-registry --host string --username string --password env:MYSECRETfunc (m *MyModule) Example(host string, username string, password *dagger.Secret) *dagger.DockerCompose {
return dag.
DockerCompose().
WithRegistry(host, username, password)
}@function
def example(host: str, username: str, password: dagger.Secret) -> dagger.DockerCompose:
return (
dag.docker_compose()
.with_registry(host, username, password)
)@func()
example(host: string, username: string, password: Secret): DockerCompose {
return dag
.dockerCompose()
.withRegistry(host, username, password)
}withSecret() 🔗
WithSecret adds a secret environment variable to inject into Docker Compose
Secrets are handled securely by Dagger and never exposed in logs. Use this for sensitive values like API keys, passwords, database URIs.
Parameters: - key: Variable name (e.g., “MONGO_URI”, “OPENAI_API_KEY”) - value: Secret value
Example:
dagger call with-secret \
--key MONGO_URI \
--value env:MONGO_URI
Return Type
DockerCompose !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| key | String ! | - | No description provided |
| value | Secret ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
with-secret --key string --value env:MYSECRETfunc (m *MyModule) Example(key string, value *dagger.Secret) *dagger.DockerCompose {
return dag.
DockerCompose().
WithSecret(key, value)
}@function
def example(key: str, value: dagger.Secret) -> dagger.DockerCompose:
return (
dag.docker_compose()
.with_secret(key, value)
)@func()
example(key: string, value: Secret): DockerCompose {
return dag
.dockerCompose()
.withSecret(key, value)
}withVariable() 🔗
WithVariable adds an environment variable to inject into Docker Compose
Use this for non-sensitive configuration values. For secrets, use WithSecret instead.
Parameters: - key: Variable name (e.g., “IMAGE_TAG”, “PORT”) - value: Variable value
Example:
dagger call with-variable --key IMAGE_TAG --value v1.2.3
Return Type
DockerCompose !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| key | String ! | - | No description provided |
| value | String ! | - | No description provided |
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@e892dda3e67a0d7b9e7a6ce65f71659d7e4c4679 call \
with-variable --key string --value stringfunc (m *MyModule) Example(key string, value string) *dagger.DockerCompose {
return dag.
DockerCompose().
WithVariable(key, value)
}@function
def example(key: str, value: str) -> dagger.DockerCompose:
return (
dag.docker_compose()
.with_variable(key, value)
)@func()
example(key: string, value: string): DockerCompose {
return dag
.dockerCompose()
.withVariable(key, value)
}DockerComposeVariable 🔗
Variable represents an environment variable with optional secret flag
key() 🔗
Return Type
String ! Example
Function DockerComposeVariable.key is not accessible from the docker-compose moduleFunction DockerComposeVariable.key is not accessible from the docker-compose moduleFunction DockerComposeVariable.key is not accessible from the docker-compose moduleFunction DockerComposeVariable.key is not accessible from the docker-compose modulevalue() 🔗
Return Type
String ! Example
Function DockerComposeVariable.value is not accessible from the docker-compose moduleFunction DockerComposeVariable.value is not accessible from the docker-compose moduleFunction DockerComposeVariable.value is not accessible from the docker-compose moduleFunction DockerComposeVariable.value is not accessible from the docker-compose modulesecret() 🔗
Return Type
Secret ! Example
Function DockerComposeVariable.secret is not accessible from the docker-compose moduleFunction DockerComposeVariable.secret is not accessible from the docker-compose moduleFunction DockerComposeVariable.secret is not accessible from the docker-compose moduleFunction DockerComposeVariable.secret is not accessible from the docker-compose module