How to fix no such service: myservice in Docker

DockerBEGINNERLOWUpdated Dec 1, 2025ยท 339 views

This error occurs when Docker Compose cannot find a service name you specified. The most common cause is using a container name instead of the service name defined in your docker-compose.yml file, or running the command from the wrong directory.

Quick fix

Fixes no such service: myservice

services:
  web:              # <-- This is the service name
    container_name: myapp  # <-- This is NOT the service name
    image: nginx

  database:         # <-- Another service name
    image: postgres
  1. Verify the service name in your docker-compose.yml
  2. Check your current working directory
  3. Use the -f flag for custom-named compose files
  4. List all available services
docker โ€” error
services:
web: # <-- This is the service name
container_name: myapp # <-- This is NOT the service name
image: nginx
database: # <-- Another service name
image: postgres
no such service: myservice

What this error means

When you run a Docker Compose command like `docker-compose up myservice`, `docker-compose logs myservice`, or `docker-compose exec myservice bash`, Docker Compose looks for a service with that exact name in the `services:` section of your `docker-compose.yml` file. The "no such service" error means Docker Compose searched through your compose file and couldn't find a service matching the name you provided. This is distinct from the container name - Docker Compose services have their own names separate from the container names they create. For example, if your compose file defines: ```yaml services: web: container_name: my-app-container image: nginx ``` The service name is `web`, NOT `my-app-container`. You must use `docker-compose up web`, not `docker-compose up my-app-container`.

Typical symptoms

  • Running 'docker-compose up <name>' shows 'no such service: <name>'
  • Commands like 'docker-compose logs', 'exec', or 'run' fail with service not found
  • Error appears immediately after typing the command, before any containers start
  • The same command worked before but now fails after changes or moving directories
  • docker-compose rm or stop fails with 'no such service' for services you thought existed

Common causes

  1. Using the container name instead of the service name from docker-compose.yml
  2. Running docker-compose from a directory that doesn't contain docker-compose.yml
  3. Typo in the service name
  4. Using a custom-named compose file without the -f flag
  5. Service was removed or renamed in the compose file
  6. Using docker-compose commands with multiple compose files without specifying all files
  7. Docker Compose v2.3+ bug when using --no-deps flag or multiple compose files
  8. Service has 0 replicas configured (Docker Compose 2.3.0+ bug)

How to fix "no such service: myservice"

1Verify the service name in your docker-compose.yml

Open your docker-compose.yml and check the exact name under services::

yaml
services:
  web:              # <-- This is the service name
    container_name: myapp  # <-- This is NOT the service name
    image: nginx

  database:         # <-- Another service name
    image: postgres

Use the name that appears as the key under services:, not the container_name value.

bash
# CORRECT - uses service name
docker-compose up web

# WRONG - uses container name
docker-compose up myapp
2Check your current working directory

Docker Compose looks for docker-compose.yml in the current directory. Verify you're in the right location:

bash
# Show current directory
pwd

# Check if docker-compose.yml exists here
ls -la docker-compose.yml

# If not found, navigate to the correct directory
cd /path/to/your/project

If you see "No such file or directory", you need to change to the directory containing your compose file.

3Use the -f flag for custom-named compose files

If your compose file has a different name (like docker-compose.dev.yml or compose.yaml), you must specify it:

bash
# For custom-named files
docker-compose -f docker-compose.dev.yml up myservice
docker-compose -f docker-compose.dev.yml logs myservice

# For multiple compose files, specify all of them
docker-compose -f docker-compose.yml -f docker-compose.override.yml up myservice

Note: Commands you run later must use the same -f flags as when you started the services.

4List all available services

To see all services defined in your compose file:

bash
# List all service names
docker-compose config --services

# Or view the full config
docker-compose config

This shows exactly what service names Docker Compose recognizes. Use one of these names in your command.

5Check for typos and case sensitivity

Service names are case-sensitive. Double-check your spelling:

yaml
services:
  WebApp:    # Case matters!
    image: nginx
bash
# WRONG - wrong case
docker-compose up webapp

# CORRECT - matches exactly
docker-compose up WebApp

Also watch for common typos like extra spaces, hyphens vs underscores, or similar-looking characters.

6Start all services without specifying a name

If you just want to start everything, omit the service name entirely:

bash
# Start all services defined in docker-compose.yml
docker-compose up -d

# View logs for all services
docker-compose logs

# Stop all services
docker-compose down

This avoids the "no such service" error by operating on all services at once.

Advanced notes

Multiple compose files: When using multiple compose files (e.g., base + override), Docker Compose merges them. If you started services with docker-compose -f docker-compose.yml -f docker-compose.prod.yml up, subsequent commands must use the same files:

bash
# This will fail if you used multiple files to start
docker-compose logs web

# This will work
docker-compose -f docker-compose.yml -f docker-compose.prod.yml logs web

Docker Compose v2 vs v1: In newer Docker installations, docker compose (with a space) is the default command instead of docker-compose (with a hyphen). Both should work the same way, but some edge cases differ.

Known bugs in Compose v2.3.x: Docker Compose versions 2.3.0-2.3.2 had several bugs causing false "no such service" errors:
- Using --no-deps flag
- Services with deploy.replicas: 0
- Complex multi-file setups

If you encounter unexplained errors, try downgrading to v2.2.3 or upgrading to a newer version:

bash
# Check current version
docker compose version

# Install specific version (if using Docker Desktop, update the app)

Profiles: If your compose file uses profiles, services with profiles are only started when that profile is active:

yaml
services:
  web:
    image: nginx

  debug:
    image: busybox
    profiles: ["debug"]  # Only available when debug profile is active
bash
# This fails - debug service requires profile
docker-compose up debug

# This works
docker-compose --profile debug up debug

Frequently asked questions

What does "no such service: myservice" mean?
yml file. The "no such service" error means Docker Compose searched through your compose file and couldn't find a service matching the name you provided. This is distinct from the container name - Docker Compose services have their own names separate from the container names they create.
How do I fix "no such service: myservice"?
This error occurs when Docker Compose cannot find a service name you specified. The most common cause is using a container name instead of the service name defined in your docker-compose.yml file, or running the command from the wrong directory.
What causes "no such service: myservice"?
Using the container name instead of the service name from docker-compose.yml Running docker-compose from a directory that doesn't contain docker-compose.yml Typo in the service name
Is the "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