How to fix no such service: myservice in Docker
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- Verify the service name in your docker-compose.yml
- Check your current working directory
- Use the -f flag for custom-named compose files
- List all available services
services:web: # <-- This is the service namecontainer_name: myapp # <-- This is NOT the service nameimage: nginxdatabase: # <-- Another service nameimage: postgresno 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
- 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
- Using a custom-named compose file without the -f flag
- Service was removed or renamed in the compose file
- Using docker-compose commands with multiple compose files without specifying all files
- Docker Compose v2.3+ bug when using --no-deps flag or multiple compose files
- Service has 0 replicas configured (Docker Compose 2.3.0+ bug)
How to fix "no such service: myservice"
Open your docker-compose.yml and check the exact name under services::
services:
web: # <-- This is the service name
container_name: myapp # <-- This is NOT the service name
image: nginx
database: # <-- Another service name
image: postgresUse the name that appears as the key under services:, not the container_name value.
# CORRECT - uses service name
docker-compose up web
# WRONG - uses container name
docker-compose up myappDocker Compose looks for docker-compose.yml in the current directory. Verify you're in the right location:
# 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/projectIf you see "No such file or directory", you need to change to the directory containing your compose file.
If your compose file has a different name (like docker-compose.dev.yml or compose.yaml), you must specify it:
# 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 myserviceNote: Commands you run later must use the same -f flags as when you started the services.
To see all services defined in your compose file:
# List all service names
docker-compose config --services
# Or view the full config
docker-compose configThis shows exactly what service names Docker Compose recognizes. Use one of these names in your command.
Service names are case-sensitive. Double-check your spelling:
services:
WebApp: # Case matters!
image: nginx# WRONG - wrong case
docker-compose up webapp
# CORRECT - matches exactly
docker-compose up WebAppAlso watch for common typos like extra spaces, hyphens vs underscores, or similar-looking characters.
If you just want to start everything, omit the service name entirely:
# 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 downThis 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:
# 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 webDocker 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:
# 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:
services:
web:
image: nginx
debug:
image: busybox
profiles: ["debug"] # Only available when debug profile is active# This fails - debug service requires profile
docker-compose up debug
# This works
docker-compose --profile debug up debugFrequently 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
- ๐Docker Official Documentation
- ๐ฌStack Overflow: docker-compose up -d No such service(Stack Overflow)
- ๐ฌStack Overflow: Docker-compose no such service(Stack Overflow)
- ๐ฌServer Fault: docker-compose no such service: myapp(Stack Overflow)
- ๐
- ๐
- ๐Docker Docs: Using multiple Compose files(Official Docs)
- ๐