How to fix Error: No such service: myservice in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 243 views

The 'No such service' error occurs when Docker Swarm cannot find a service matching the name you specified. This typically happens when the service was never deployed, has been removed, or you're running commands against a non-swarm node. Verify the service exists with docker service ls.

Quick fix

Fixes Error: No such service: myservice

# List all services in the swarm
docker service ls

# Filter by name pattern
docker service ls --filter "name=myservice"

# Show detailed output
docker service ls --format "table {{.ID}}\t{{.Name}}\t{{.Mode}}\t{{.Replicas}}"
  1. List all services to verify what exists
  2. Verify you're on a swarm manager node
  3. Check for stack prefix in service names
  4. Create or deploy the missing service
docker โ€” error
# List all services in the swarm
docker service ls
# Filter by name pattern
docker service ls --filter "name=myservice"
# Show detailed output
docker service ls --format "table {{.ID}}\t{{.Name}}\t{{.Mode}}\t{{.Replicas}}"
Error: No such service: myservice

What this error means

The "Error: No such service" message in Docker Swarm indicates that the Docker daemon cannot locate a service matching the name or ID you provided in your command. Docker Swarm maintains a registry of all services deployed to the cluster. When you issue commands like `docker service ps myservice`, `docker service logs myservice`, or `docker service rm myservice`, Swarm searches for a service with that exact name. If no match is found, it returns this error. This error can also occur in Docker Compose (v2+) contexts, particularly with certain command combinations or version-specific regressions. However, in the Swarm context, it simply means the service doesn't exist in the current swarm cluster.

Typical symptoms

  • Docker service commands fail with 'No such service: servicename'
  • docker service ps, logs, inspect, or rm commands return the error immediately
  • CI/CD pipelines fail when trying to update or scale swarm services
  • docker stack deploy shows service but docker service commands can't find it
  • Rolling update or scale operations fail on non-existent services
  • Scripts that previously managed services now fail after redeployment

Common causes

  1. Service was never created or deployed to the swarm
  2. Service was removed or the stack was deleted
  3. Typo in the service name
  4. Running command on a worker node instead of a manager node
  5. Node is not part of a swarm (swarm mode not initialized)
  6. Service name doesn't include stack prefix when deployed via docker stack
  7. Wrong Docker context selected (different swarm cluster)
  8. Service deployment failed silently and service was never created
  9. Docker Compose v2 regression with certain flag combinations (--no-deps, profiles)

How to fix "Error: No such service: myservice"

1List all services to verify what exists

First, check what services are currently deployed in your swarm:

bash
# List all services in the swarm
docker service ls

# Filter by name pattern
docker service ls --filter "name=myservice"

# Show detailed output
docker service ls --format "table {{.ID}}\t{{.Name}}\t{{.Mode}}\t{{.Replicas}}"

If your service doesn't appear in the list, it either wasn't deployed or has been removed.

2Verify you're on a swarm manager node

Docker service commands must be run on a manager node. Check your node status:

bash
# Check if this node is in swarm mode
docker info | grep -i swarm

# Check if this is a manager node
docker node ls

# If you see "This node is not a swarm manager", you need to:
# 1. SSH to a manager node, or
# 2. Initialize swarm if not done: docker swarm init

Worker nodes cannot run service management commands. You'll get "This node is not a swarm manager" before "No such service" if running on a worker.

3Check for stack prefix in service names

When you deploy services via docker stack deploy, the stack name becomes a prefix:

bash
# Deploying with stack
docker stack deploy -c docker-compose.yml mystack

# Service "web" becomes "mystack_web"
docker service ls
# NAME         MODE        REPLICAS   IMAGE
# mystack_web  replicated  3/3        nginx:latest

# Use the full name with prefix
docker service ps mystack_web

# Or list services in a specific stack
docker stack services mystack

Always use the full service name including the stack prefix when using docker service commands.

4Create or deploy the missing service

If the service doesn't exist, you need to create it:

bash
# Create a simple service
docker service create --name myservice nginx

# Create with replicas
docker service create --name myservice --replicas 3 nginx

# Deploy from a compose file
docker stack deploy -c docker-compose.yml mystack

# Or using docker-compose in swarm mode
docker compose up -d

After creation, verify with docker service ls to confirm the service exists.

5Check Docker context for multi-cluster setups

If you manage multiple swarm clusters, ensure you're targeting the correct one:

bash
# List all Docker contexts
docker context ls

# See which context is active (marked with *)
docker context show

# Switch to a different context
docker context use production-swarm

# Or specify context for a single command
docker --context production-swarm service ls

Services created in one cluster won't be visible when connected to a different cluster.

6Inspect stack deployment for silent failures

Sometimes stack deployments fail silently. Check for deployment issues:

bash
# List all stacks
docker stack ls

# Check services in a stack
docker stack services mystack

# View detailed task information (shows failures)
docker stack ps mystack --no-trunc

# Check for failed tasks
docker stack ps mystack --filter "desired-state=shutdown"

# Get detailed error messages
docker service ps myservice --no-trunc --filter "desired-state=shutdown"

Look for tasks in "Rejected" or "Failed" state to understand why the service didn't start.

7Handle Docker Compose v2 specific issues

Docker Compose v2.3+ has known issues with "No such service" errors in certain scenarios:

bash
# Check your compose version
docker compose version

# Known issues occur with:
# - --no-deps flag with healthcheck dependencies
# - Services with profiles
# - Multiple compose files

# Workarounds:
# 1. Remove --no-deps if using service dependencies
docker compose up myservice  # instead of docker compose up --no-deps myservice

# 2. Explicitly specify profile when restarting
docker compose --profile myprofile restart myservice

# 3. Update to latest Docker Compose version
docker compose version
# Consider updating if below 2.20

These are typically version-specific regressions that get fixed in later releases.

Advanced notes

### Understanding Swarm Service Discovery

In Docker Swarm, services are cluster-wide objects managed by the swarm manager. Unlike standalone containers, services:

- Are only visible on manager nodes via docker service commands
- Have names that are cluster-unique (no two services can have the same name)
- Are automatically load-balanced across replicas
- Persist their definition in the Raft consensus store

bash
# Service is visible via swarm commands
docker service ls
docker service inspect myservice

# Individual containers (tasks) are visible on all nodes
docker ps  # Shows containers on current node only

### Difference Between Containers and Services

A common source of confusion:

bash
# These are different things:
docker ps                    # Lists containers (local to this node)
docker service ls            # Lists services (cluster-wide)

# A service named "web" creates containers like:
# web.1.abc123 (on node1)
# web.2.def456 (on node2)

# You can docker exec into the container, not the service:
docker exec -it web.1.abc123 bash    # Works
docker exec -it web bash             # Doesn't work

### Service Inspection and Debugging

For detailed troubleshooting:

bash
# Get service configuration
docker service inspect myservice --pretty

# Check why tasks failed
docker service ps myservice --no-trunc

# Get logs from all service replicas
docker service logs myservice

# Follow logs in real-time
docker service logs -f myservice

# Get logs from a specific task
docker service logs myservice.1

### Global vs Replicated Services

Services can run in different modes:

bash
# Replicated: specific number of instances (default)
docker service create --replicas 3 --name web nginx

# Global: one instance per swarm node
docker service create --mode global --name monitoring prometheus

# The mode affects how you reference and scale services
docker service scale web=5       # Only works for replicated mode

### Handling Rolling Updates to Non-Existent Services

When automating deployments, always check if the service exists first:

bash
# Check if service exists before updating
if docker service inspect myservice > /dev/null 2>&1; then
    docker service update --image nginx:latest myservice
else
    docker service create --name myservice nginx:latest
fi

# Or use docker stack deploy which handles both create and update
docker stack deploy -c docker-compose.yml mystack

### Swarm Service vs Docker Compose Service

The term "service" has different meanings:

| Context | Definition | Commands |
|---------|------------|----------|
| Swarm | Cluster-wide service definition | docker service |
| Compose | Service defined in compose file | docker compose |
| Compose on Swarm | Compose service deployed to swarm | docker stack |

When you docker stack deploy, compose services become swarm services with stack name prefixes.

Frequently asked questions

What does "Error: No such service: myservice" mean?
The "Error: No such service" message in Docker Swarm indicates that the Docker daemon cannot locate a service matching the name or ID you provided in your command. Docker Swarm maintains a registry of all services deployed to the cluster. When you issue commands like docker service ps myservice, docker service logs myservice, or docker service rm myservice, Swarm searches for a service with that exact name.
How do I fix "Error: No such service: myservice"?
The 'No such service' error occurs when Docker Swarm cannot find a service matching the name you specified. This typically happens when the service was never deployed, has been removed, or you're running commands against a non-swarm node. Verify the service exists with docker service ls.
What causes "Error: No such service: myservice"?
Service was never created or deployed to the swarm Service was removed or the stack was deleted Typo in the service name
Is the "Error: No such service: myservice" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading