Dagger
Search

docker-compose

This module provides Docker Compose operations with chainable configuration
for 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@1f3a971841f4a2cdcbf593eda036b2f114a123e7

Entrypoint

Return Type
DockerCompose !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 registry-host
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 registry-username
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 registry-password
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 variables
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 sshhost
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 sshuser
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 sshport
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 sshkey
func (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@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 env-file
func (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()
}

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”) - projectName: Docker Compose project name (optional, uses directory name if not set)

Example:

dagger call deploy \
  --source . \
  --compose-path docker/docker-compose.yml \
  --project-name chat
Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-No description provided
composePathString "docker-compose.yml"No description provided
projectNameString -No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 deploy --source DIR_PATH
func (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”) - projectName: Docker Compose project name (optional, uses directory name if not set)

Example:

dagger call down \
  --source . \
  --compose-path docker/docker-compose.yml \
  --project-name chat
Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-No description provided
composePathString "docker-compose.yml"No description provided
projectNameString -No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 down --source DIR_PATH
func (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”) - 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 \
  --tail 50 \
  --project-name chat
Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-No description provided
composePathString "docker-compose.yml"No description provided
tailInteger 100No description provided
projectNameString -No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 logs --source DIR_PATH
func (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)
}

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”) - projectName: Docker Compose project name (optional, uses directory name if not set)

Example:

dagger call status \
  --source . \
  --compose-path docker/docker-compose.yml \
  --project-name chat
Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-No description provided
composePathString "docker-compose.yml"No description provided
projectNameString -No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 status --source DIR_PATH
func (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
NameTypeDefault ValueDescription
hostString !-No description provided
userString !-No description provided
portInteger 22No description provided
sshKeySecret !-No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 with-context --host string --user string --ssh-key env:MYSECRET
func (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
NameTypeDefault ValueDescription
envFileFile !-No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 with-env-file --env-file file:path
func (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
NameTypeDefault ValueDescription
hostString !-No description provided
usernameString !-No description provided
passwordSecret !-No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 with-registry --host string --username string --password env:MYSECRET
func (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
NameTypeDefault ValueDescription
keyString !-No description provided
valueSecret !-No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 with-secret --key string --value env:MYSECRET
func (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
NameTypeDefault ValueDescription
keyString !-No description provided
valueString !-No description provided
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/containers/docker-compose@1f3a971841f4a2cdcbf593eda036b2f114a123e7 call \
 with-variable --key string --value string
func (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 module
Function DockerComposeVariable.key is not accessible from the docker-compose module
Function DockerComposeVariable.key is not accessible from the docker-compose module
Function DockerComposeVariable.key is not accessible from the docker-compose module

value() 🔗

Return Type
String !
Example
Function DockerComposeVariable.value is not accessible from the docker-compose module
Function DockerComposeVariable.value is not accessible from the docker-compose module
Function DockerComposeVariable.value is not accessible from the docker-compose module
Function DockerComposeVariable.value is not accessible from the docker-compose module

secret() 🔗

Return Type
Secret !
Example
Function DockerComposeVariable.secret is not accessible from the docker-compose module
Function DockerComposeVariable.secret is not accessible from the docker-compose module
Function DockerComposeVariable.secret is not accessible from the docker-compose module
Function DockerComposeVariable.secret is not accessible from the docker-compose module