Skip to content

force recreate

github-actions[bot] edited this page Oct 6, 2026 · 2 revisions

Force-Recreate Semantics

For an app-only target, force-recreate tears down a Compose project with no shutdown grace period, then creates fresh containers even when Compose sees no configuration or image change. frec is an exact alias for the command.

Syntax

<cmd> force-recreate <app>
<cmd> force-recreate <app1> <app2>
<cmd> force-recreate all
<cmd> force-recreate all except <app1> <app2>

<cmd> frec <same-selection>

App names are directory names, not Compose service or container names. DAM resolves them from its configured search directories. The all selector includes discovered Compose applications except names configured in EXCLUDE_DIRS; all except validates every excluded name before doing work.

Use <app>:<service> to force-recreate one service without taking down the whole project:

<cmd> force-recreate <app>:<service>

For a service target, DAM runs stop -t 0 and rm -f for that service (ignoring errors from those two preparatory commands), then runs up -d --force-recreate <service>. The project-wide down flow below applies when no service is specified.

Per-App Flow

For each selected application, DAM finds the first recognized Compose filename in this order:

  1. compose.yaml
  2. compose.yml
  3. docker-compose.yaml
  4. docker-compose.yml

It changes into that directory and runs the available Compose implementation, preferring docker compose and falling back to docker-compose:

docker compose [-f <file>...] down --remove-orphans -t 0
docker compose [-f <file>...] up -d --force-recreate
docker compose ps # whole app target
docker compose ps <service> # service target

The final status command is informational. A failure to print status does not change an otherwise successful teardown and startup result.

Step 1: Immediate Teardown

docker compose [-f <file>...] down --remove-orphans -t 0

-t 0 requests a zero-second shutdown timeout. This is the key difference from recreate.md: services receive no normal grace period to finish work before Compose removes them. Use it only when a graceful recreate cannot stop the stack or when immediate replacement is acceptable.

--remove-orphans also removes containers belonging to services that are no longer present in the current Compose definition.

By default, Compose project volumes and images are preserved. The command does not run DAM's global image, network, volume, or build-cache cleanup.

Step 2: Forced Creation

docker compose [-f <file>...] up -d --force-recreate

--force-recreate tells Compose to replace service containers regardless of whether its change detection believes replacement is necessary. The stack is started detached using the current Compose configuration; Compose creates the project networks and containers again as needed.

Step 3: Status Display

docker compose ps # whole app target
docker compose ps <service> # service target

DAM displays the resulting service state. For an app-only target, the action succeeds only when both the teardown and startup commands succeed. In the service-target form, errors from the preliminary stop -t 0 and rm -f are ignored; the final up result determines success.

Explicit Compose Files

Append using <file1> <file2>... to select Compose files explicitly. If none of the requested files resolve for an app, force-recreate fails that app instead of tearing down and rebuilding the stack described by its default Compose file. If one or more resolve, DAM uses only the resolved files and warns about any misses.

Selection, Failures, and Summary

DAM processes selected apps sequentially. An app that cannot be found, resolves to more than one directory, is excluded, or fails one of the Compose operations is recorded in the final summary. A failure for one app does not prevent later selected apps from being attempted. DAM exits nonzero if any app failed.

Excluded applications are skipped, even when explicitly named. force-recreate requires a reachable Docker daemon and either supported Compose implementation before it starts selection processing.

A single-app operation does not require confirmation. force-recreate all (including all except) requires the exact interactive response yes, unless -y/--yes is supplied. The operation is disruptive but does not remove volumes or images; use recreate.md when a normal shutdown is sufficient.

Examples

# Force replacement of one hung stack.
dkr force-recreate immich

# The compact alias has identical behavior.
dkr frec <app-name>

# Replace all targetable stacks except infrastructure that should remain up.
dkr force-recreate all except <app3> <app4>

What It Does Not Do

  • It does not pull newer images or rebuild local images. Use update.md for that workflow.
  • It does not remove named volumes or service images.
  • With an app-only target, it affects the whole Compose project. With app:service, it uses the service-specific stop/remove/up flow described above instead.
  • It does not support Swarm or Kubernetes.

Clone this wiki locally