---
title: "ECS dependsOn condition never met: init, sidecar or app container? | Proofline"
description: "Read each container's exit code and health status beside the revision's dependsOn graph to find the container that broke the chain."
url: https://proofline.sh/learn/ecs-container-dependency-blocks-start/
---

[Learning center](/learn/)

# ECS dependsOn condition never met: init, sidecar or app container?

Read each container's exit code and health status beside the revision's dependsOn graph to find the container that broke the chain. An app container with no exit code was held back by a dependency; one with an exit code ran and failed by itself.

Broken dependencies The Proofline team November 22, 2026 6 min read

## How a dependency holds a container back

A task definition can make one container wait for another with `dependsOn`, naming a container and a condition. If the condition is not met, or times out first, ECS does not move the waiting container to its next state, so it never starts. The task then never reaches `RUNNING` with its app. [ContainerDependency](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDependency.html) · [Container dependency parameters](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html)

| Condition | The waiting container starts when the named container | How it is never met |
| --- | --- | --- |
| `START` | Has started | The named container cannot be created or started |
| `COMPLETE` | Has exited, with any exit code | The named container keeps running |
| `SUCCESS` | Has exited with exit code 0 | It exits non-zero, or keeps running |
| `HEALTHY` | Passes the health check in its container definition | It has no `healthCheck` in the revision, or its check keeps failing |

Two documented rules matter most for init containers. `COMPLETE` and `SUCCESS` can't be set on an essential container, and a container whose `essential` field is omitted counts as essential. When an essential container stops for any reason, ECS stops every other container in the task. [ContainerDefinition essential](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html)

`HEALTHY` has a trap of its own. ECS monitors only health checks declared in the container definition. A `HEALTHCHECK` built into the image's Dockerfile is not monitored, and a container with no declared check reports `UNKNOWN`, which never becomes `HEALTHY`. [HealthCheck](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_HealthCheck.html) · [Container health status](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Container.html)

`startTimeout` bounds the wait. In AWS's example, container A depends on container B reaching `COMPLETE`, `SUCCESS` or `HEALTHY`, and a `startTimeout` set on B makes A give up when B misses that status in time; the task then moves to `STOPPED`. On Fargate the valid values are 2 to 120 seconds. On EC2, the agent's `ECS_CONTAINER_START_TIMEOUT` setting is enforced independently. [startTimeout](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html)

## Read the graph and the containers

Use a read-only profile and replace the uppercase placeholders. First the revision's graph, with the fields that decide each edge:

```
aws ecs describe-task-definition \
  --profile PROFILE --region REGION --task-definition TASK_DEFINITION_ARN \
  --query 'taskDefinition.containerDefinitions[].{name:name,essential:essential,dependsOn:dependsOn,startTimeout:startTimeout,healthCheck:healthCheck.command,command:command}' \
  --output json --no-cli-pager
```

If `essential` shows `null`, the field was omitted, and the container counts as essential. Then the stopped task, container by container. ECS keeps stopped tasks for at least one hour. [Task fields](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Task.html) · [Stopped task retention](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/stopped-task-errors.html)

```
aws ecs describe-tasks \
  --profile PROFILE --region REGION --cluster CLUSTER --tasks TASK_ARN \
  --query 'tasks[].{definition:taskDefinitionArn,code:stopCode,reason:stoppedReason,started:startedAt,stopped:stoppedAt,containers:containers[].{name:name,status:lastStatus,exit:exitCode,reason:reason,health:healthStatus}}' \
  --output json --no-cli-pager
```

Walk the graph from the app container back through its dependencies. The first container on that path that exited non-zero, never turned healthy, or stayed running when it was meant to finish is the one to fix. Read its own logs and reason; the waiting containers have none.

## What each pattern means

| Dependency container | App container | Reading | Change |
| --- | --- | --- | --- |
| Init container with `SUCCESS`, exit code non-zero | No exit code | The init step failed; the app was never allowed to start | Fix the init step; its logs hold the error |
| Init container with `COMPLETE` or `SUCCESS`, still running when the task stopped | No exit code | The init step did not finish within `startTimeout` | Find out why it hangs, or give it a longer `startTimeout` |
| Sidecar with `HEALTHY`, health `UNKNOWN`, no `healthCheck` in the revision | No exit code | The condition can never be met | Declare a `healthCheck` in the sidecar's container definition |
| Sidecar with `HEALTHY`, health `UNHEALTHY` | No exit code | The sidecar's own check fails | Read the sidecar's logs and its check command |
| Init container used with `START` and left essential, exit code 0 | Stopped | The init container's normal exit stopped the task | Set `essential` to `false` and use `SUCCESS` |
| Every dependency met: exit code 0 or `HEALTHY` | Exit code set | The app ran and failed by itself | Treat it as a process exit; the app's logs are the next read |

If a dependency container never started at all and its own reason begins `CannotStartContainerError`, the command or image is the problem, which [the command-not-found guide](/learn/ecs-cannotstartcontainer-command-not-found/) covers. For the last row, the stop code is usually `EssentialContainerExited`, and [the stop code guide](/learn/ecs-task-stop-codes/) sorts what follows.

## Two ways orders:63 can fail

This fixture is illustrative. The fictional service `orders` moves to `orders:63`, which adds two containers in front of `app`: `migrate`, an init container with `essential` set to `false` that `app` waits on with `SUCCESS`, and `proxy`, a sidecar that `app` waits on with `HEALTHY`. `proxy` has a `startTimeout` of 120 seconds.

| Container | Init failure | Health check missing |
| --- | --- | --- |
| `migrate` | Exit code 1 | Exit code 0 |
| `proxy` | Running, health `HEALTHY` | Running, health `UNKNOWN`; the revision has no `healthCheck`, the image has a Dockerfile `HEALTHCHECK` |
| `app` | No exit code | No exit code |
| Task | Never reached `RUNNING` | Stopped about two minutes after `proxy` started |

In the first case the graph stopped at `migrate`. Its log shows the failure, and `app` was correct to wait. Fix the migration and redeploy; nothing about `app` changed. In the second case `migrate` succeeded and `proxy` was running, but ECS had no declared check to evaluate, so `proxy` stayed `UNKNOWN` until its `startTimeout` ran out. The image's own `HEALTHCHECK` does not count. Copy the check into `proxy`'s container definition as `healthCheck`.

Had `app` shown exit code 1 with `migrate` at 0 and `proxy` `HEALTHY`, the dependencies would be cleared and the app itself would be the failure.

## Confirm on the replacement task

On the replacement, read the same container query. Each dependency should show the state its condition asks for: exit code 0 for `SUCCESS`, an exit code for `COMPLETE`, `HEALTHY` for `HEALTHY`. The app container should be running with no exit code, and the task should have a `startedAt`. If the service has a load balancer, its target health is the next read once the task runs.

## Where this reading stops

None of the seven stop codes is specific to an unmet dependency, so the container records are the evidence. Two conditions are weaker than they look. `START` waits only for the named container to start, so an app that needs an init step to finish can start too early and fail by itself; use `SUCCESS` for that. `HEALTHY` is checked only at task startup, so a sidecar that turns unhealthy later does not hold anything back. [ContainerDependency](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDependency.html)

Container dependencies need ECS agent 1.26.0 or later on EC2, and Linux platform version 1.3.0 or later, or Windows platform version 1.0.0 or later, on Fargate. Dependencies also reverse at shutdown, so the app container stops before the containers it depends on. [ContainerDependency](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDependency.html)

This guide is one of the ordering rows in [the signature table](/learn/aws-deployment-failure-signatures/).

## Questions

### Why does my ECS app container never start when it depends on another container?

ECS does not start a container until each `dependsOn` condition is met. Check the named container: a non-zero exit fails `SUCCESS`, a container that keeps running never meets `COMPLETE`, and a container with no declared health check never becomes `HEALTHY`.

### Does ECS use the HEALTHCHECK from my Docker image for a HEALTHY dependency?

No. ECS monitors only the `healthCheck` in the container definition, and reports `UNKNOWN` for a container without one. Declare the check in the task definition.

### Should an init container be marked essential?

No. `COMPLETE` and `SUCCESS` can't be set on an essential container, and an essential container that exits stops the whole task. Set `essential` to `false` and have the app wait on it with `SUCCESS`.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which ECS task stops came from your deployment? Read the stop code](/learn/ecs-task-stop-codes/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [ECS container won't start: CannotStartContainerError or exit code 127](/learn/ecs-cannotstartcontainer-command-not-found/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
