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.
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`.
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.
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 debugdockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec