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.

Write web up -d --wait Open 8080

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.

01

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.

02

-d is what remains

docker compose up --detach starts containers in the background and leaves them running. --wait implies detached mode as well.

03

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. 1

    Write one service

    Create compose.yaml in a project directory. Name the service web, use nginx:latest from 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 has db. Leave it out.

  2. 2

    Start detached and wait

    In that directory run docker compose up -d --wait. -d is --detach: after the command returns, the container keeps running. up without -d stops every container when the command exits.

  3. 3

    Confirm with ps

    docker compose ps lists running containers only, with status and ports. PORTS should show host port 8080. An empty list means you should add --all or --status=exited before assuming the file did nothing.

  4. 4

    Open the host port

    Open http://localhost:8080. A response is the reachable service. With no healthcheck, --wait only tells you the container is running, not that HTTP succeeded.

1
service
-d
leaves it up
no
default restart
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.0 and 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 down removes the containers. docker compose stop keeps them, but they are not running, and default ps hides them.
If the file has more services
Usage is docker compose up [SERVICE...]. In the simple example, web has no depends_on, so docker compose up -d web does not start db. --no-deps skips 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.

Create a free space