compose up leaves one service reachable
Foreground up stops the containers on exit. -d leaves one Nginx service running, and port 8080 can still answer.
A foreground docker compose up stops the containers when you leave. docker compose up -d is what leaves one service running and reachable. To mark who can open that port, create a space on tidemeet.
The search is docker compose up leaves one service up. The docs say the command stops every container on exit. docker compose up --detach starts them in the background and leaves them running.
Foreground up does not stick
docker compose up builds, creates, starts, and attaches to container logs. When that command ends, the containers stop. Detached mode is the case where the command returns and the service is still up.
Foreground up stops
Official wording: when the command exits, all containers are stopped. Ctrl+C is SIGINT. The containers stop, and the exit code is 0.
-d is what remains
docker compose up --detach starts containers in the background and leaves them running. --wait implies detached mode as well.
The default does not revive
restart defaults to no: it does not restart the container under any circumstances. One crash, and it stays down.
Leave one service up and reachable
-
1
Write one service
Create
compose.yamlin a project directory. Name the serviceweb, usenginx:latestfrom the official simple example, and publish a quoted"8080:80"(host:container). Without quotes, YAML can read the mapping as a base-60 float. That example also hasdb. Leave it out. -
2
Start detached and wait
In that directory run
docker compose up -d --wait.-dis--detach: after the command returns, the container keeps running.upwithout-dstops every container when the command exits. -
3
Confirm with ps
docker compose pslists running containers only, with status and ports. PORTS should show host port 8080. An empty list means you should add--allor--status=exitedbefore assuming the file did nothing. -
4
Open the host port
Open
http://localhost:8080. A response is the reachable service. With no healthcheck,--waitonly tells you the container is running, not that HTTP succeeded.
services:
web:
image: nginx:latest
ports:
- "8080:80"
docker compose up -d --wait
docker compose ps
Three outcomes
| Command | After it returns | Port |
|---|---|---|
| docker compose up | Exit stops the containers | Unreachable |
| docker compose up -d | Container keeps running | See if 8080 answers |
| Plus unless-stopped | A crash is restarted until stop or remove | Still depends on the bind |
- Binds every interface
- With no host IP, Docker binds
0.0.0.0and can bypass host firewall rules. On a public machine, keep the first service local with"127.0.0.1:8080:80". - down removes it
docker compose downremoves the containers.docker compose stopkeeps them, but they are not running, and defaultpshides them.- If the file has more services
- Usage is
docker compose up [SERVICE...]. In the simple example, web has nodepends_on, sodocker compose up -d webdoes not start db.--no-depsskips linked services.
When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.
When someone else needs the port map
Once the port answers, the remaining job is who can reach it. No extra meeting suite. Open a short space on tidemeet, or see how to create a space. Canvas: shared whiteboard. For a short alignment, temporary meeting tools says when a browser space is enough.
Questions
Does up without -d count as staying up?
No. When the command exits, including Ctrl+C, Compose stops the containers. Exit code 0 does not mean the service is still running.
Does --wait mean the page loads?
No. This Nginx service has no healthcheck. --wait returns when the service is running or healthy. Reachable means the host port answers.
Will a crash bring it back?
Not by default. restart is no. unless-stopped keeps restarting until you stop or remove the service.
Is it still running after down?
No. down removes the containers. stop keeps them, but they are not running.