Repository navigation
update
This document explains exactly how DAM's update command works, including custom update scripts, state preservation, and post-update behavior.
The update command is DAM's most complex lifecycle operation. For each app, it follows one of two paths:
-
Custom script path - if an
update*.shscript exists in the app directory - Standard compose path - pull images, build, recreate
The standard Compose path accepts <app>:<service> and limits the running-state check, pull, build, startup, and final status query to that service. A discovered custom update script is app-level and runs without a service filter, even if the request used app:service.
When no custom script is found (or the user declines to run it):
When this standard Compose path runs, append using <file1> <file2>... to select files explicitly. If none of the requested files resolve for an app, update logs an informational message and falls back to that app's default Compose file. If one or more resolve, DAM uses only the resolved files and warns about any misses. A permitted update*.sh runs instead of the Compose path and does not consume these file selections.
Before making any changes, DAM checks whether the app has any running containers:
# Get container IDs for the project
running_containers="$(docker compose ps -q)"
# Check if any are actually running
docker inspect -f '{{.State.Running}}' "$cid"This determines whether the app should be restarted after the update.
# Preferred (newer Docker Compose):
docker compose [-f <file>...] pull --ignore-buildable
# Fallback (older Docker Compose):
docker compose [-f <file>...] pull --ignore-pull-failuresDAM dynamically checks whether --ignore-buildable is supported by inspecting docker compose pull --help. If the flag is not found in the help output, it falls back to --ignore-pull-failures.
--ignore-buildable skips services that have a build section (since they'll be built locally, not pulled from a registry).
--ignore-pull-failures is the older equivalent - it ignores pull failures (which includes services that can't be pulled because they're meant to be built).
If pull fails entirely (e.g., image not found, registry down), Docker's exact error message will be printed to your screen, and the update process will immediately abort for this specific app (preventing broken containers from being created).
docker compose [-f <file>...] build --pullThis rebuilds any services that have a build section in the Compose file. The --pull flag ensures that base images (the FROM line in Dockerfiles) are refreshed from the registry, not just pulled from the local cache.
If build fails, the update is aborted for this app.
If the app was running:
docker compose [-f <file>...] up -dThis recreates containers with the newly pulled/built images. Docker Compose detects that images have changed and recreates the relevant containers.
If the app was stopped:
[INFO] Skipping container startup (app was stopped).
The app remains stopped. Images are updated, but containers are not recreated. The next time the app is started (via start or recreate), it will use the new images.
docker compose psDAM searches for files matching the glob update*.sh in the app directory:
find "$dir" -maxdepth 1 -name "update*.sh" -print0 | sort -zOnly the first script alphabetically is selected. For example, if a directory contains:
update-backup.shupdate-migrate.shupdate.sh
DAM will select update-backup.sh (alphabetically first).
Note: Only one custom script is executed per update. If you need multiple steps, combine them into a single script.
The behavior depends on ALLOW_CUSTOM_UPDATE_SCRIPTS:
ALLOW_CUSTOM_UPDATE_SCRIPTS |
Terminal Available | Behavior |
|---|---|---|
true |
Any | Script runs immediately, no prompt |
false (default) |
Yes (TTY) | Prompts: "Do you want to run this custom update script? [y/N]" |
false (default) |
No (no TTY) | Warning logged, falls back to compose update |
pushd "$dir"
bash "$(basename "$custom_script")"- The script is executed via
bash, not sourced - Working directory is set to the app directory
- The script's exit code determines success/failure
- If the script succeeds, no further update steps are taken
- If the script fails, the app is marked as failed
Custom update scripts are arbitrary shell scripts that DAM executes. See Safety & Security for security implications.
After all apps have been processed, DAM runs a global dangling resource cleanup:
cleanup_dangling_resources "${safe_cleanup_modes[@]}"By default (no with modifiers):
-
Dangling images only:
docker image prune -f
┌─────────────────┐
│ update <app> │
└────────┬────────┘
│
▼
┌────────────────────┐
│ Has update*.sh? │
└──┬─────────────┬───┘
│ Yes │ No
▼ │
┌──────────────┐ │
│ Allowed? │ │
└──┬────────┬──┘ │
│ Yes │ No │
▼ │ │
┌────────────┐ │ │
│ Run script │ │ │
└──┬──────┬──┘ │ │
│ │ │ │
Success Fail │ │
│ │ ▼ ▼
│ │ ┌──────────────────┐
│ │ │ Check running │
│ │ │ state │
│ │ └────────┬─────────┘
│ │ │
│ │ ▼
│ │ ┌──────────────────┐
│ │ │ pull images │
│ │ │ --ignore- │
│ │ │ buildable │
│ │ └────────┬─────────┘
│ │ │
│ │ ▼
│ │ ┌──────────────────┐
│ │ │ build --pull │
│ │ └────────┬─────────┘
│ │ │
│ │ ▼
│ │ ┌──────────────────┐
│ │ │ Was running? │
│ │ └──┬────────────┬──┘
│ │ │ Yes │ No
│ │ ▼ ▼
│ │ ┌────────┐ ┌──────────┐
│ │ │ up -d │ │ Skip │
│ │ └───┬────┘ │ startup │
│ │ │ └────┬─────┘
│ │ │ │
▼ ▼ ▼ ▼
┌────────────────────────────────┐
│ Show status │
│ docker compose ps │
└────────────────────────────────┘
# Update a single app (standard compose flow)
dkr update <app-name>
# Update all apps except specific apps
dkr update all except <app3>
# Update an app with a custom set of compose files
dkr update myapp using compose dev prod