> ## Content Index
> Fetch the complete content index at: https://debugly.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# Why Compose Didn’t Restart the App After a Dependency Crash
- URL: https://debugly.dev/compose-depends-on-restart-runtime-recovery/
- Published: 2026-11-14T00:07:00.000Z
- Updated: 2026-11-14T00:07:00.000Z
- Description: Compose dependency restarts and Docker runtime restarts have different owners. Diagnose why the dependency recovered while its client stayed running.
- Author: Rohit Bhadani
- Tags: Docker, Infrastructure, Debugging

The cache container crashes, Docker brings it back, and the application keeps reporting connection errors. You already set `depends_on` with `restart: true`. The missing restart may be expected: that dependency option applies to explicit Compose operations, not automatic restarts performed by the container runtime after a container dies. Recovering a dependency and reconnecting its clients are separate jobs.

*This is an AI-prepared, documentation-based explainer, not a personally reproduced incident. The configuration fragments and checks are illustrative and were not executed for this article. See the* [*editorial policy*](https://debugly.dev/editorial-policy/)*.*

## Two restart settings, two different owners

Imagine an app that opens a connection to a cache at startup. The cache exits and its runtime restart policy brings it back. The app process survives, but its client keeps using a broken connection. A manual restart of the app makes requests work again. That’s a clue about client recovery; it isn’t proof that Docker ignored your configuration.

The confusing part is that two different settings contain the same word. These illustrative fragments belong inside an existing Compose project; they omit image, networking and application configuration:

```
services:
  app:
    depends_on:
      cache:
        condition: service_started
        restart: true

  cache:
    restart: unless-stopped
```

The cache’s service-level `restart: unless-stopped` is a [container restart policy](https://docs.docker.com/engine/containers/start-containers-automatically/?ref=debugly.dev). The `restart: true` nested under the app’s dependency relationship describes what Compose does when it explicitly updates or restarts that dependency. The [Compose reference](https://docs.docker.com/reference/compose-file/services/?ref=debugly.dev#depends%5Fon) explicitly excludes automated runtime restarts from that relationship. The nested option was introduced in Compose 2.17.0; check your actual Compose version before assuming support.

That dependency edge doesn’t make Compose an ongoing recovery controller for runtime restarts. The word “restart” is doing two jobs and has declined to wear a name badge.

## Find out who performed the restart

First record the command or event that caused the cache to stop. Was it a process exit followed by Docker’s restart policy, an explicit `docker compose restart cache`, a Compose update, or a different tool? Don’t use one of those paths to prove the behavior of another.

```
docker compose version
docker compose ps --all
```

The [ps reference](https://docs.docker.com/reference/cli/docker/compose/ps/?ref=debugly.dev) explains why `--all` matters: the default listing only shows running containers. Match the project, service names and container IDs to the incident. Then inspect only the metadata you need. This illustrative command uses a placeholder container name or ID:

```
docker inspect --format   '{{.Name}} started={{.State.StartedAt}} restarts={{.RestartCount}} policy={{.HostConfig.RestartPolicy.Name}}'   cache-container-id
```

Compare the app’s start time too. A runtime restart count and timestamps help build a timeline, but they don't tell the whole cause by themselves. Container recreation changes identity; a counter on the replacement doesn’t describe the removed container. Correlate with available engine events, Compose command output and application logs. Avoid dumping the full container configuration just to inspect a restart counter; environment values may contain credentials.

If an explicit Compose operation also fails to propagate the expected restart, that is a different branch. Confirm the effective dependency configuration, Compose version, selected project and command options. For example, [docker compose restart --no-deps](https://docs.docker.com/reference/cli/docker/compose/restart/?ref=debugly.dev) suppresses restarting dependent services. Also remember that `restart` does not apply edited Compose configuration; after changing a dependency relationship, use the project’s normal configuration-application workflow before testing it.

## A healthy startup is not continuous recovery

[Compose’s startup guide](https://docs.docker.com/compose/how-tos/startup-order/?ref=debugly.dev) distinguishes a running dependency from a ready one. If the app must wait for readiness during startup, use an appropriate health check and `condition: service_healthy`. The fragment above deliberately uses `service_started`, which doesn’t make that stronger promise.

That health-based startup gate still isn't a promise to restart an already running app whenever the cache becomes unhealthy later. Treat the dependency’s readiness, its process restart, the app’s connection recovery and the app’s own readiness as separate checks. A green cache health check doesn’t establish that existing client connections were repaired.

If the app is meant to stay running through a cache outage, its client needs a bounded recovery policy: detect broken connections, discard unusable pool entries, reconnect with backoff, and expose failure when the required dependency is unavailable. Check the particular client’s documented behavior rather than adding a blind retry around every command. A connection failure after a write was sent can leave the result uncertain; retrying an operation with side effects needs its own correctness policy.

## Test the outage path you actually need

In a disposable environment, test a dependency process exit with its runtime policy separately from an explicit Compose restart. Also test a dependency that remains running but temporarily cannot serve requests. Record whether the app process restarted, whether it reconnected, and whether a real request succeeded. Those are three different outcomes.

If the app cannot reconnect and a restart is the accepted recovery mechanism, put that action under an explicit, monitored recovery owner with readiness checks and restart-loop limits. Don’t infer that a dependency edge in Compose implements it. For planned maintenance, an intentional Compose restart can be useful; for an unexpected outage, application recovery must be designed and verified.

Debugly’s [dependency-sensitive liveness investigation](https://debugly.dev/liveness-probe-depended-on-database/) shows the related danger of turning a dependency outage into unnecessary application restarts. Here the useful question comes one step earlier: which component owns recovery, and what evidence says the client is usable again?