Docker
action: docker.run runs one step in a container. Dagu creates the container from an image (or uses a running one), runs the command, streams its output to the step log, and uses the container's exit code as the step result.
To run run: steps in containers, or every step of a DAG in one shared container, use the container field. Use docker.run when a step needs Docker Engine options such as memory limits or privileged mode.
Basic Usage
steps:
- id: hello
action: docker.run
with:
image: alpine:3
command: echo "Hello from a container"
auto_remove: trueThe step log shows Hello from a container, and the step succeeds when the container exits with code 0. Without auto_remove: true, the stopped container stays on the Docker host after the step.
Mount Files
volumes takes source:target[:ro|rw]. working_dir sets the directory inside the container.
working_dir: .
steps:
- id: build
action: docker.run
with:
image: golang:1.24
working_dir: /src
volumes:
- ./app:/src
- go-cache:/root/go/pkg/mod
command: go build -o bin/app ./cmd/app
auto_remove: true- A source that starts with
/,., or~, or contains a slash, is a bind mount. A relative path resolves against the step working directory. - Any other source, such as
go-cache, is a named Docker volume. $VARand${VAR}in the source expand from the Dagu process environment. A missing variable fails the step before the container starts.
When Dagu itself runs in Docker, the daemon resolves bind sources on the host, not inside the Dagu container. Use paths that exist on the host, or named volumes.
Use a Shell in the Container
command is not run through a shell. Dagu splits the string into arguments, so |, &&, >, and $VAR reach the program as plain text. Set shell to run the command with a shell inside the container:
steps:
- id: count_files
action: docker.run
with:
image: alpine:3
shell: ["sh"]
command: ls /etc | wc -l
auto_remove: trueDagu adds -c when the shell arguments lack it. Dagu references such as ${params.date} are resolved on the host before the container starts.
Run Several Commands
A list runs each command in the same container, in order, and stops at the first failure. Files written by one command are visible to the next.
working_dir: .
steps:
- id: test
action: docker.run
with:
image: node:22
working_dir: /app
volumes:
- ./web:/app
command:
- npm ci
- npm test
auto_remove: trueWith a list, Dagu starts the container with a keep-alive process instead of the image's default command, then runs each entry with docker exec.
Run in an Existing Container
container_name without image runs the command in a container that is already running, such as a Docker Compose service. Dagu waits up to 120 seconds for it to be running.
steps:
- id: migrate
action: docker.run
with:
container_name: app-web
exec:
User: www-data
WorkingDir: /var/www
command: php artisan migrate --forceexec sets Docker exec options and is valid only with container_name.
Set Environment Variables and Limits
container, host, and network pass Docker Engine API objects through unchanged. Keys use the API names, matched without regard to case.
params:
- region: eu-west-1
steps:
- id: report
action: docker.run
with:
image: ghcr.io/example/report:1.4
container:
Env:
- REGION=${params.region}
- LOG_LEVEL=info
host:
Memory: 536870912 # 512 MiB
NanoCpus: 1000000000 # 1 CPU
command: ./generate --out /tmp/report.csv
auto_remove: trueThe container receives the image's variables and container.Env. Step and DAG env are not passed in, so reference them with ${env.NAME} as above. CPU and memory limits from DAG Run Resource Limits also apply to new containers.
Configuration
action: container.run is an alias of docker.run. Set image, container_name, or both.
| Field | Required | Default | Description |
|---|---|---|---|
image | One of image or container_name | Image for a new container. | |
container_name | One of image or container_name | Without image: a running container to exec into. With image: the name of the new container. | |
command | No | Image CMD | Command for the container. A string is split into arguments; a list runs each entry in order. |
shell | No | None | Shell inside the container that runs command, such as ["bash", "-o", "pipefail"]. |
pull | No | missing | always, missing, never, or fallback. true means always, false means never. |
auto_remove | No | false | Remove the container after the step ends. |
platform | No | Daemon platform | Image platform, such as linux/arm64. |
working_dir | No | Image default | Working directory in the container. |
volumes | No | None | Mounts as source:target[:ro|rw]. |
container | No | None | Docker container config, such as Env, User, Entrypoint, Labels. |
host | No | None | Docker host config, such as Memory, NanoCpus, Privileged, NetworkMode. |
network | No | None | Docker networking config, such as EndpointsConfig. |
exec | No | None | Docker exec options, such as User, WorkingDir, Env. Requires container_name. |
Pull policies:
pull | Behavior |
|---|---|
always | Pull before every run. |
missing | Pull only when no matching local image exists. |
never | Use the local image only. |
fallback | Try to pull; on failure, use the local image. Fail if neither works. |
Output
- Logs: the container's stdout and stderr go to the step log. On failure, the step error includes the last lines of stderr.
- Exit code: the container's exit code (or the failing command's, for a list) is the step's exit code.
- Values: capture stdout with
output: NAME, or save it as an artifact withstdout.artifact. See Capturing Stdout.
Registry Authentication
registry_auths at the DAG level supplies credentials when Dagu pulls an image. Keys are registry hosts as they appear in image names.
registry_auths:
ghcr.io:
username: ${env.GITHUB_USER}
password: ${env.GITHUB_TOKEN}
gcr.io:
auth: ${env.GCR_AUTH_BASE64} # base64 of username:password
steps:
- id: analyze
action: docker.run
with:
image: ghcr.io/example/analyzer:2
command: analyze --all
auto_remove: trueregistry_authsalso accepts a whole Docker config JSON string, as in~/.docker/config.json:registry_auths: ${env.DOCKER_AUTH_CONFIG}.- When
registry_authsis set but has no entry for an image's registry, Dagu readsDOCKER_AUTH_CONFIGfrom the Dagu process environment. - Values resolve DAG references such as
${env.NAME}. Declare host variables in DAGenvorsecretsfirst.
The same credentials apply to the container field.
Docker Daemon Access
Dagu talks to the Docker Engine API. Containers start on whichever daemon Dagu connects to.
| Where Dagu runs | Setup |
|---|---|
| On a Docker host | Nothing. Dagu uses the local Docker socket. |
| Inside Docker | Mount the host socket. Containers start as siblings on the host. |
| Remote daemon | Set DOCKER_HOST and, for TLS, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH on the Dagu process. |
| Podman | Set DAGU_CONTAINER_RUNTIME=podman. Set DAGU_PODMAN_HOST when the socket is not unix:///run/podman/podman.sock. |
DAGU_CONTAINER_RUNTIME=podman \
DAGU_PODMAN_HOST=unix:///run/user/1000/podman/podman.sock \
dagu start-allThese are process settings, not DAG fields. In a distributed setup, every worker that runs container steps needs daemon access. See Podman sandbox setup for socket details.
Errors and Limits
- A step with neither
imagenorcontainer_namefails validation. execwithimageand nocontainer_namefails validation.- A multi-line
commandstring fails validation. Use a list, orshellwith a one-line command. - With
container_nameandimage, a running container of that name is reused; a stopped one is removed and created again. timeout_secand a stop request stop the container with the step'ssignal_on_stop(or the daemon default), then kill it after the DAG'smax_clean_up_time_sec.

