no service selected from docker compose up means that, with the
profiles active for this run, no service in the file is enabled. In this test every
service carried a profiles: key and no profile was active. Name a profile with
--profile or the COMPOSE_PROFILES variable and the services in it
start.
docker compose --profile dev up -d started the service tagged
dev. Setting COMPOSE_PROFILES=dev in the shell did the same with a
plain docker compose up -d.
The error
PS> docker compose up -d
no service selected
The command exited with code 1 and created nothing. The file that produced it:
name: fix9-cmp-c5
services:
web:
image: alpine
command: ["sleep", "300"]
profiles: ["dev"]
seed:
image: alpine
command: ["sleep", "300"]
profiles: ["tools"]
Why it happens
A service with a profiles: key is left out of a run unless one of its profiles
is active. In this file both
services carry a profile, web in dev and seed in
tools, and the first command named none, so the run had nothing to start and
Compose said so.
So the message is about the run, not the file: the same file starts fine as soon as a profile is named, as the fix below shows.
The fix
PS> docker compose --profile dev up -d
Network fix9-cmp-c5_default Creating
...
Container fix9-cmp-c5-web-1 Started
PS> docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
fix9-cmp-c5-web-1 alpine "sleep 300" web Less than a second ago Up Less than a second
Only web started; seed, in the tools profile, stayed
out. The project was then removed with docker compose --profile dev down -v.
The same result without the flag, by setting the variable in PowerShell first:
PS> $env:COMPOSE_PROFILES='dev'
PS> docker compose up -d
Network fix9-cmp-c5_default Creating
...
Container fix9-cmp-c5-web-1 Started
PS> docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
fix9-cmp-c5-web-1 alpine "sleep 300" web 1 second ago Up Less than a second
The variable stays set for the rest of that PowerShell window, so the next
up in it picks the same profile; remove it with
Remove-Item Env:COMPOSE_PROFILES when you are done.
If one service should start on a plain docker compose up, take its
profiles: line out instead. With the line removed from web and
seed still in tools, a plain docker compose up -d
started web alone:
PS> docker compose up -d
...
Container fix9-cmp-c5-web-1 Started
PS> docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
fix9-cmp-c5-web-1 alpine "sleep 300" web 1 second ago Up Less than a second
How it was reproduced
Two alpine services running sleep 300, each in its own profile,
started with docker compose up -d, then with --profile dev, then
with COMPOSE_PROFILES set, from Windows PowerShell 5.1 on Docker Engine 29.9.3
and Docker Compose v5.7.0 (Docker Desktop on Windows 11). The project name carries this
test's fix9-cmp- prefix and was removed with docker compose down -v.
Frequently asked
- Why does docker compose up say no service selected?
- Every service in the file had a profiles key and no profile was active, so the run had nothing to start. The command exited with code 1 and created nothing.
- How do I start a Docker Compose profile?
- Pass it on the command line, docker compose --profile dev up -d, or set COMPOSE_PROFILES=dev in the shell and run docker compose up -d. Both started the dev service in this test.
- How do I make a service start without a profile?
- Remove its profiles line. A service with a profiles key is left out of a run until one of its profiles is active.
More decoded errors in the Fixes category. When the service you name is not in the file at all, see Docker Compose: no such service.