Skip to content
DevOps AI ToolKit
Newsletter
All guides
Docker with AI By James Joyner IV · · 9 min read Last reviewed Jul 2026

Docker Error Guide: 'failed to create service' docker stack deploy Failure

Quick answer

Fix 'docker stack deploy' errors like 'failed to create service', 'network not found', and 'this node is not a swarm manager': diagnose swarm state, networks, and stack references.

  • #docker
  • #troubleshooting
  • #errors
  • #swarm
Free toolkit

Stuck on this Docker with AI error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Exact Error Message

$ docker stack deploy -c docker-compose.yml myapp
Creating network myapp_frontend
Creating service myapp_web
failed to create service myapp_web: Error response from daemon: network myapp_backend not found

Other common variants from the same command include:

Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
failed to create service myapp_web: Error response from daemon: rpc error: code = InvalidArgument desc = port '80' is already in use by service 'myapp_old'

What It Means

docker stack deploy translates a Compose file into Swarm services, networks, and configs, then asks the Swarm manager to create each one. The command fails when the daemon cannot satisfy part of that request: the node is not a manager, a referenced network or config does not exist, a published port collides, or a service definition is invalid.

Unlike docker compose up, stack deploy requires an active Swarm and only runs against a manager node. Partial deploys are common: some services are created before the failing one, which is why you often see a mix of “Creating” lines followed by a single “failed to create” error.

Common Causes

  • The current node is not a Swarm manager (Swarm was never initialized, or you are on a worker).
  • A service references an external network that has not been created, or a typo’d internal network name.
  • A published port is already bound by another running service.
  • The Compose file uses version or keys that Swarm mode ignores or rejects (for example build: without a pre-built image).
  • An external config or secret referenced in the file does not exist in the Swarm.
  • Image pull failure on the manager during service creation.

Diagnostic Commands

Confirm the node is a manager and Swarm is active:

docker info --format '{{.Swarm.LocalNodeState}} / {{.Swarm.ControlAvailable}}'

List existing networks to check what the stack expects versus what exists:

docker network ls

Inspect the failing service’s tasks for the detailed error:

docker stack ps myapp --no-trunc

Validate the Compose file’s Swarm interpretation before deploying:

docker stack config -c docker-compose.yml

Step-by-Step Resolution

  1. Confirm Swarm and manager status. If docker info shows inactive, initialize Swarm; if you are on a worker, run the command from a manager:
docker swarm init
  1. Create any external networks the stack references before deploying. If the file declares a network as external: true, Docker will not create it for you:
docker network create --driver overlay --attachable myapp_backend
  1. Fix internal network typos. If the network is meant to be created by the stack, ensure the service’s networks: entries exactly match the top-level networks: keys in the Compose file.

  2. Resolve port conflicts. Find the service holding the port and either remove it or change the published port in your Compose file:

docker service ls --filter publish=80
docker service rm myapp_old
  1. Create missing external configs or secrets before the deploy references them:
docker config create myapp_nginx ./nginx.conf
docker secret create myapp_db_password ./db_password.txt
  1. Re-run the deploy. Stack deploy is idempotent, so it reconciles the already-created services and adds the previously failed one:
docker stack deploy -c docker-compose.yml myapp
  1. Verify every service reached its desired replica count:
docker stack services myapp
ID             NAME         MODE         REPLICAS   IMAGE
a1b2c3d4e5f6   myapp_web    replicated   1/1        nginx:latest

Prevention

  • Run docker stack config -c docker-compose.yml in CI to catch invalid keys and unresolved references before they hit a live cluster.
  • Provision external overlay networks, configs, and secrets as an explicit setup step, and keep those commands next to the stack file.
  • Avoid build: in stack files; Swarm ignores it. Build and push images to a registry first, then reference them by tag.
  • Use unique published ports per stack, or route through a reverse proxy so services do not compete for the same host port.
  • Always deploy from a manager node, and script a manager-status check into your deploy pipeline so worker-node mistakes fail fast.
  • Pin image tags rather than latest so redeploys are reproducible and pull failures are easier to trace.
  • This node is not a swarm manager — Swarm is not initialized or you are on a worker node.
  • network <name> not found — an external network was referenced but never created.
  • no suitable node (scheduling constraints not satisfiable) — the service was created but cannot be placed.
  • rpc error: code = InvalidArgument desc = port is already in use — a published-port collision with another service.

Frequently Asked Questions

Why does stack deploy fail when docker compose up works? They target different runtimes. docker compose up runs standalone containers on one host; docker stack deploy requires an active Swarm and a manager node, and it ignores Compose keys like build: that Swarm does not support.

How do I create the network the error is complaining about? If the network is marked external: true, create it yourself with docker network create --driver overlay --attachable <name>. If it is meant to be managed by the stack, fix the name mismatch instead.

Is docker stack deploy safe to re-run after a partial failure? Yes. It is declarative and idempotent. Re-running reconciles existing services and creates only what is missing, so fixing the root cause and deploying again is the normal recovery path.

Why do I get ‘not a swarm manager’ on a node that is in the cluster? Worker nodes cannot accept stack deploys. Run the command from a manager, or promote the node with docker node promote from an existing manager.

Where can I find more deployment troubleshooting help? Generate step-by-step fixes tailored to your stack with the DevOps AI prompt library, and see more Docker guides.

Free download · 368-page PDF

Fixed it? Get 500 Docker with AI & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.