Description
Currently, when deploying a stack in Docker Swarm using docker stack deploy, the depends_on configuration is ignored. While docker-compose up respects this parameter to orchestrate the startup sequence of containers, Swarm mode drops it. This creates a significant gap in functionality for teams relying on Swarm for production orchestration.
Motivation / Use Case
For large enterprises and complex architectures that still heavily rely on Docker Swarm, controlling the startup order of interdependent services is a critical, basic requirement.
A very common scenario is a backend application that must wait for a database (Oracle, PostgreSQL, SQL Server) to be fully initialized and healthy before starting its own migrations or connection pools. Without depends_on in Swarm mode, the dependent services crash upon startup, leading to a cascade of errors until the database is finally ready.
Proposed Solution
Enable docker stack deploy to respect the depends_on directive, specifically integrating with health checks (condition: service_healthy or condition: service_started). The Swarm manager should hold the scheduling or the start of the dependent tasks until the target service meets the required condition across the cluster.
Alternatives Considered & Current Workarounds
To bypass this limitation today, developers are forced to implement suboptimal workarounds:
Entrypoint wrappers (wait-for-it.sh, dockerize): This adds unnecessary boilerplate to Dockerfiles, requires altering official images, and moves orchestration logic inside the container.
Aggressive Restart Policies (restart_policy: condition: on-failure): This forces the application into a deliberate crash-loop until dependencies are ready. It pollutes monitoring tools, generates excessive log noise, spikes initial CPU load, and makes it harder to distinguish between a genuine crash and a startup delay.
Additional Context
Bringing the Swarm deployment behavior closer to the Compose specification regarding service dependency will drastically improve the developer experience and the reliability of automated deployments in enterprise environments.
Description
Currently, when deploying a stack in Docker Swarm using docker stack deploy, the depends_on configuration is ignored. While docker-compose up respects this parameter to orchestrate the startup sequence of containers, Swarm mode drops it. This creates a significant gap in functionality for teams relying on Swarm for production orchestration.
Motivation / Use Case
For large enterprises and complex architectures that still heavily rely on Docker Swarm, controlling the startup order of interdependent services is a critical, basic requirement.
A very common scenario is a backend application that must wait for a database (Oracle, PostgreSQL, SQL Server) to be fully initialized and healthy before starting its own migrations or connection pools. Without depends_on in Swarm mode, the dependent services crash upon startup, leading to a cascade of errors until the database is finally ready.
Proposed Solution
Enable docker stack deploy to respect the depends_on directive, specifically integrating with health checks (condition: service_healthy or condition: service_started). The Swarm manager should hold the scheduling or the start of the dependent tasks until the target service meets the required condition across the cluster.
Alternatives Considered & Current Workarounds
To bypass this limitation today, developers are forced to implement suboptimal workarounds:
Entrypoint wrappers (wait-for-it.sh, dockerize): This adds unnecessary boilerplate to Dockerfiles, requires altering official images, and moves orchestration logic inside the container.
Aggressive Restart Policies (restart_policy: condition: on-failure): This forces the application into a deliberate crash-loop until dependencies are ready. It pollutes monitoring tools, generates excessive log noise, spikes initial CPU load, and makes it harder to distinguish between a genuine crash and a startup delay.
Additional Context
Bringing the Swarm deployment behavior closer to the Compose specification regarding service dependency will drastically improve the developer experience and the reliability of automated deployments in enterprise environments.