Skip to content

Self HostingGuide

docker compose up -d Explained

  • Updated
  • 15 min read
  • VPS Lane Engineering
Short answer

docker compose up -d creates or updates the services in your Compose file, starts them in the background and returns your prompt.

How we tested this

Commands shown with output were run on Ubuntu 24.04.5 LTS (x86_64) as root, with Docker Engine 29.9.3 and Docker Compose v5.7.0 from the official Docker packages, using the images nginx:1.29-alpine (nginx 1.29.8) and redis:8-alpine (Redis 8.12.0), plus busybox:latest for the pull test. Images were fetched through the mirror.gcr.io copy of Docker Hub after Docker Hub returned its rate limit error. Some output is trimmed for readability, and the page says where. A restart of the Docker daemon was used to test restart policies, not a full reboot of the machine. The systemctl and journalctl commands were not run, because the test machine has no systemd, and follow the Docker documentation. Timings come from single runs and are not benchmarks. Docker Desktop on Windows and macOS was not tested.

What docker compose up -d Does

What docker compose up -d does depends on two parts: up brings the project to the state in the file and -d detaches.

The up command reads your Compose file, resolves the image for each service and creates the networks, volumes and containers it needs. It starts services in dependency order, waiting for dependencies with condition: service_healthy to pass their health checks. Whether it pulls or builds an image depends on the image, build and pull_policy settings of the service. For a service without a build section, the default missing pull policy makes Compose pull the image only when it is not in the local cache, except that the Compose Specification says latest is always pulled. If a service has both image and build but no pull_policy, Compose tries to pull first, then builds from source if the image is not found in the registry or the local cache. In testing, a service using the image reference demo-pullfirst:1.0 printed pull access denied, then Building and Built. An explicit pull_policy changes that behaviour. The -d flag is short for --detach. Without it, up stays attached and streams every container log to your terminal.

Each part of the command
PartWhat it isWhat it does here
dockerThe Docker CLITalks to the Docker daemon through its socket
composeThe Compose plugin (v2 and later)Reads compose.yaml and manages the whole project
upThe main Compose commandBuilds images when required, creates or recreates containers as needed, starts services and by default attaches to their output
-d or --detachA flag of upStarts the containers in the background and returns the prompt

Compose looks for compose.yaml first, and also accepts compose.yml, docker-compose.yaml and docker-compose.yml. Use -f to point at another file, for example docker compose -f prod.yaml up -d. The project name defaults to the folder name, which is why the containers below are called demo-web-1 and demo-cache-1. Use -p to set it yourself, for example docker compose -p production up -d, which in testing created production-web-1, production-cache-1, the production_default network and the production_cache-data volume.

What You Need Before You Start

You need Docker Engine with the Compose plugin, a Compose file and permission to use the Docker socket before you start.

  • Linux with Docker Engine and the docker-compose-plugin package installed. Steps here were tested on Ubuntu 24.04 and work the same way on other distributions that use the official packages.
  • A user that is root, uses sudo, or is in the docker group. Membership of that group gives root level access to the host, so add only trusted users.
  • A folder with a valid compose.yaml in it.

The Compose File Used in This Guide

The Compose file used in this guide runs nginx as a web service and Redis as a cache with a named volume and a health check.

If containers are new to you, read how a Docker container works first. The file is small on purpose, but it has the parts that make detached stacks behave differently: a published port, a dependency that must be healthy first, a restart policy and data that lives in a volume.

yaml
services:
  web:
    image: nginx:1.29-alpine
    ports:
      - "8088:80"
    restart: unless-stopped
    depends_on:
      cache:
        condition: service_healthy
  cache:
    image: redis:8-alpine
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5
    volumes:
      - cache-data:/data
volumes:
  cache-data:

There is no top level version: line. Current Compose ignores it and prints a warning when it is present, as the version section further down shows.

Run docker compose up -d Step by Step

To run docker compose up -d, check the versions, move into the project folder, start the stack and confirm it with ps.

  1. Check Docker and ComposeRun docker compose version. A reply such as Docker Compose version v5.7.0 means the plugin is installed. If the shell says the command is unknown, install the docker-compose-plugin package.
  2. Go to the project folderRun cd into the folder that holds compose.yaml, or pass the file with -f.
  3. Start the stack in the backgroundRun docker compose up -d and wait for the prompt to return.
  4. Check the containersRun docker compose ps and look for Up in the STATUS column.
  5. Test the service itselfRequest the published port, because a running container does not prove the app inside answers.
bash
docker compose version
docker compose up -d
Output
Docker Compose version v5.7.0
 Volume demo_cache-data Creating 
 Volume demo_cache-data Created 
 Network demo_default Creating 
 Network demo_default Created 
 Container demo-cache-1 Creating 
 Container demo-cache-1 Created 
 Container demo-web-1 Creating 
 Container demo-web-1 Created 
 Container demo-cache-1 Starting 
 Container demo-cache-1 Started 
 Container demo-cache-1 Waiting 
 Container demo-cache-1 Healthy 
 Container demo-web-1 Starting 
 Container demo-web-1 Started

This output is from the first run. Lines that Compose printed twice in non interactive mode were left out, and on a real terminal you see the same steps as a live progress view. The order matters: cache had to report Healthy before web was started, because of condition: service_healthy. The whole run took 7.8 seconds here, most of it spent waiting for the health check.

To start only one service, add its name, as in docker compose up -d web. In testing that started cache as well, because web depends on it, and --no-deps skips dependencies.

bash
docker compose ps
curl -sI http://127.0.0.1:8088 | head -2
Output
NAME           IMAGE               COMMAND                  SERVICE   CREATED         STATUS                   PORTS
demo-cache-1   redis:8-alpine      "docker-entrypoint.s…"   cache     7 seconds ago   Up 6 seconds (healthy)   6379/tcp
demo-web-1     nginx:1.29-alpine   "/docker-entrypoint.…"   web       7 seconds ago   Up Less than a second    0.0.0.0:8088->80/tcp
HTTP/1.1 200 OK
Server: nginx/1.29.8

0.0.0.0:8088->80/tcp means port 8088 on every IPv4 address of the host goes to port 80 in the container. From another machine you would open http://203.0.113.10:8088, where 203.0.113.10 is an example documentation address standing in for your server IP. On a host with IPv6 enabled, Docker can publish the port on [::] as well.

Docker Compose Up vs Up -d

Docker Compose up vs up -d differs in one way: up stays attached to the logs, while up -d returns once the containers have started.

docker compose up compared with docker compose up -d
Behaviourdocker compose updocker compose up -d
TerminalStays busy and streams logs from every serviceReturns the prompt when the containers have started
Ctrl+CStops all the containers it startedNothing to press, the stack keeps running
Closing the SSH sessionCan stop the stack, as a hangup signal (SIGHUP) did in testing, depending on how the session endsContainers keep running, independent of the session
Seeing logsLive in the terminalRun docker compose logs
Waits for app readinessNoNo, unless you add --wait
Typical useWatching a first start or debuggingServers, long running stacks and scripts

This attached run was stopped with Ctrl+C, sent here as SIGINT after 12 seconds. The output is trimmed to the first and last lines, and the many Redis and nginx startup lines in between were removed.

bash
docker compose up
Output
 Container demo-web-1 Created 
Attaching to cache-1, web-1
 Container demo-cache-1 Starting 
 Container demo-cache-1 Started 
 Container demo-cache-1 Waiting 
cache-1  | Starting Redis Server
web-1    | 2026/12/03 11:48:02 [notice] 1#1: start worker process 21
 Compose Stopping Gracefully Stopping... press Ctrl+C again to force
 Container demo-web-1 Stopping 
 Container demo-web-1 Stopped 
 Container demo-cache-1 Stopping 
 Container demo-cache-1 Stopped

Afterwards docker compose ps -a showed both containers as Exited (0). That is one reason to use -d on a server. Ctrl+C stops the containers that the attached command manages, and closing the SSH session can do the same, depending on how the session handles it. Detached containers run independently of the terminal. By default they stop when the Docker daemon shuts down, unless live restore is enabled.

Docker Compose Up vs Start vs Run

Docker Compose up, start and run differ: up creates or recreates containers, start starts stopped ones and run creates a one off container.

up compared with start and run
CommandWhat it doesCreates containers
docker compose up -dCreates what is missing, applies changes and starts the projectYes, when missing or changed
docker compose startStarts containers that were created before and then stoppedNo
docker compose run --rm web nginx -vRuns a one off command in a new container created from the service configurationYes, a separate one off container

In testing, run started the healthy cache dependency first, then printed nginx version: nginx/1.29.8 from a container named demo-web-run-80d3d16cbce7. A one off container started with run showed only 80/tcp and no host port, because run does not publish the service ports unless you add --service-ports.

What Detached Mode Does Not Do

Detached mode does not check that your app works or keep logs on screen. It does not control crash recovery either.

A configured restart policy, such as restart: unless-stopped in the example file, is what can restart a crashed container.

A successful exit from docker compose up -d means Compose completed the startup request. It does not guarantee that every container is still running or that the app is healthy. This test service prints an error and exits with code 1 straight away.

yaml
services:
  worker:
    image: nginx:1.29-alpine
    command: ["sh", "-c", "echo DATABASE_URL is not set; exit 1"]
bash
docker compose up -d; echo EXIT=$?
docker compose ps -a --format 'table {{.Service}}\t{{.Status}}'
docker compose logs worker
Output
 Container bad-worker-1 Starting 
 Container bad-worker-1 Started 
EXIT=0
SERVICE   STATUS
worker    Exited (1) 2 seconds ago
worker-1  | DATABASE_URL is not set

Compose reported success with exit code 0, and the container was already dead. Plain docker compose ps printed an empty table, because by default it lists running containers only. The -a flag showed the failure and the logs showed why.

Wait for Healthy Services With --wait

The --wait flag makes Compose wait until services are running or healthy, and it returns an error if a container exits instead.

bash
docker compose up -d --wait; echo EXIT=$?
Output
 Container bad-worker-1 Started 
 Container bad-worker-1 Waiting 
container bad-worker-1 exited (1)
EXIT=1

On the healthy demo stack the same flag returned EXIT=0 after 10.2 seconds, once Redis passed its health check. Use --wait in scripts and deploy jobs so a broken start fails the job. Add --wait-timeout 120 to cap the wait in seconds.

A pass only means each container is running and every service with a healthcheck reported healthy. A service with no health check counts as ready the moment it runs, so a health check that tests the real app is what makes the result meaningful.

View Logs After docker compose up -d

To view logs after docker compose up -d, run docker compose logs, add -f to follow them and a service name to filter.

Useful docker compose logs commands
CommandWhat it shows
docker compose logsAll logs from every service in the project
docker compose logs -fLive logs that keep streaming until Ctrl+C, which stops only the log view
docker compose logs --tail 50 webThe last 50 lines of the web service
docker compose logs --since 10mLines from the last 10 minutes
docker compose logs -t webAdds a timestamp to every line
bash
docker compose logs --tail 2 -f web
Output
web-1  | 2026/12/03 11:48:30 [notice] 1#1: start worker process 20
web-1  | 172.18.0.1 - - [03/Dec/2026:11:48:31 +0000] "GET / HTTP/1.1" 200 896 "-" "curl/8.5.0" "-"

The prefix web-1 is the service name plus the replica number. Pressing Ctrl+C in logs -f ends the log view only, and the containers keep running. With the default logging setup, logs are removed together with the container when docker compose down runs, while an external logging driver may keep them elsewhere. Copy or export anything you need before removing containers. Logs and images also take disk space over time, so check disk space usage on Linux now and then on a small server.

Check Status With docker compose ps

To check status, docker compose ps lists the running containers of the project with their state, health and published ports.

bash
docker compose ps --format 'table {{.Service}}\t{{.State}}\t{{.Status}}'
docker compose ls
Output
SERVICE   STATE     STATUS
cache     running   Up 16 seconds (healthy)
web       running   Up 10 seconds
NAME                STATUS              CONFIG FILES
app                 running(1)          /root/w/compose-up-d/app/compose.yaml
demo                running(2)          /root/w/compose-up-d/demo/compose.yaml

Up means the container process is running, not that the app answers. (healthy) appears only for services with a health check and means that check passed, so test the app itself when availability matters. docker compose ls lists running Compose projects with the file each came from. Add --all to include stopped projects, which helps when you need to find a stack that is no longer running. Add -a to ps to include stopped and exited containers.

Restart Docker Compose Services

To restart Docker Compose services, run docker compose restart for all of them or add a service name for one.

bash
docker compose restart web
Output
 Container demo-web-1 Restarting 
 Container demo-web-1 Started

A restart keeps the same container, so it does not apply edits to compose.yaml or .env. In testing, the published port was changed from 8088 to 8089 in the file and web was restarted, and ps still showed 0.0.0.0:8088->80/tcp. Use docker compose up -d whenever the configuration changed.

Running docker compose up -d Again

Running docker compose up -d again is generally safe with the same project and file, because unchanged containers are reused.

Compose recreates only services affected by a detected change, and those can be interrupted briefly while that happens.

bash
docker compose up -d
Output
 Container demo-cache-1 Running 
 Container demo-web-1 Running 
 Container demo-cache-1 Waiting 
 Container demo-cache-1 Healthy

Running means Compose left that container alone. Compose tracks containers by project and service name, so a re-run with the same project name and file does not create a second copy of the stack. It creates containers that are missing and recreates those affected by a detected change or by the flags you pass. After changing the published port of web from 8088 to 8089 in the file, the same command replaced only that container.

Output
 Container demo-cache-1 Running 
 Container demo-web-1 Recreate 
 Container demo-web-1 Recreated 
 Container demo-cache-1 Waiting 
 Container demo-cache-1 Healthy 
 Container demo-web-1 Starting 
 Container demo-web-1 Started

A recreated container is a new container. Data in named volumes and bind mounts survives, while anything written inside the container filesystem itself is lost. These flags change the default.

Flags that control recreation
FlagEffectUse it when
--force-recreateRecreates containers even if nothing changedYou changed a file the container reads only at start, such as a mounted config
--no-recreateNever recreates existing containersYou only want to start missing services
--no-deps webStarts or recreates web without starting its dependencies, and leaves running dependency containers as they areReplacing one service in a running stack
--remove-orphansRemoves containers of services no longer in the fileYou renamed or deleted a service

Recreating a container restarts it, so expect a short gap in service, and plan forced recreation for a quiet moment on a busy server.

Update Containers With Pull and Build

To update containers, pull new images or rebuild yours, then run docker compose up -d so Compose swaps only the changed ones.

bash
docker compose pull
docker compose up -d
Output
 Image redis:8-alpine Pulling 
 Image nginx:1.29-alpine Pulling 
 Image redis:8-alpine Pulled 
 Image nginx:1.29-alpine Pulled 
 Container demo-cache-1 Running 
 Container demo-web-1 Running

pull only downloads. It never touches running containers. In a separate test with Compose v5.7.0, no Pulling line appeared for a cached busybox:latest image. That output alone does not show whether Compose reused the local image or checked the registry, and under the default missing policy the spec says latest is always pulled. To refresh images on purpose run docker compose pull first or use docker compose up -d --pull always. Here both tags were already current, so up -d left both containers Running. When a newer image arrives, the same command shows Recreate for that service only.

Rebuild Images With --build

For services built from a Dockerfile, --build rebuilds the image before up -d starts it, using the build cache.

In this test a page copied into the image was edited. A plain up -d reused the existing demo-site:latest image and kept serving the old page, so a changed Dockerfile or build context is not a reason for up to rebuild on its own.

bash
docker compose up -d --build
Output
 Image demo-site:latest Building 
#6 [1/2] FROM docker.io/library/nginx:1.29-alpine@sha256:5616878291a2eed594aee8db4dade5878cf7edcb475e59193904b198d9b830de
#6 CACHED
#7 [2/2] COPY site/ /usr/share/nginx/html/
#7 DONE 0.1s
 Image demo-site:latest Built 
 Container app-site-1 Recreate 
 Container app-site-1 Recreated 
 Container app-site-1 Starting 
 Container app-site-1 Started

The base layer came from CACHED and only the COPY step ran again, which shows that --build does not skip the cache. To build with no cache at all, run docker compose build --no-cache and then docker compose up -d. There is no --no-cache flag on up itself.

Bind Mounts Need No Rebuild

Files in a bind mount need no rebuild, because the container reads them straight from the host folder.

With ./site:/usr/share/nginx/html:ro mounted, editing site/index.html changed the served page from version 3 to version 4 at once, with no command at all. Apps that cache files in memory or read config only at start still need a restart, which docker compose restart web does.

Which command picks up which change
What changedCommandWhat happens
New image for a tag in a registrydocker compose pull then docker compose up -dChanged services are recreated
Your Dockerfile or code copied into the imagedocker compose up -d --buildImage rebuilt with cache, container recreated
Settings in compose.yamldocker compose up -dOnly the affected services are recreated
Files in a bind mounted folderNone, or docker compose restart webVisible straight away to the container
Values in .env used by the filedocker compose up -dRecreated where the rendered config changed

Stop vs Down vs Down -v in Docker Compose

In Docker Compose, stop halts containers but keeps them, down removes containers and networks, and down -v also removes volumes.

What each Compose command removes
CommandStops containersRemoves containersRemoves networksRemoves named volumes
docker compose stopYesNoNoNo
docker compose downYesYesYesNo
docker compose down -vYesYesYesYes, plus anonymous volumes

stop is not pause, which is a separate command that freezes processes. None of the three deletes images, and volumes marked external are never removed. Stopped containers come back with docker compose start, which only starts containers that already exist. After a down it fails like this.

Output
service "cache" has no container to start

Use docker compose up -d after a down, because up creates what is missing. To show what -v really costs, a key was written to Redis and saved to the volume.

bash
docker compose exec cache redis-cli set visits 42
docker compose exec cache redis-cli save
docker compose down && docker compose up -d --wait
docker compose exec cache redis-cli get visits
Output
OK
OK
42

The value survived a plain down because the demo_cache-data volume was kept. After docker compose down -v the output included Volume demo_cache-data Removed, and the same get returned (nil) after the next start, confirming that the key was deleted with the volume.

Keep Compose Containers Running After a Reboot

To keep Compose containers running after a reboot, give each service a restart policy and make sure Docker starts at boot.

The -d flag only decides where the output goes. It has no effect on what happens when the daemon or the server restarts. Restart behaviour is set by the restart: key instead.

Restart policies in a Compose file
ValueAfter a crashAfter a daemon restart or rebootAfter you stop it by hand
no (default)Stays stoppedStays stoppedStays stopped
on-failureRestarts if the exit code was not 0Not restartedStays stopped
alwaysRestartsRestartsStays stopped until you start it or the daemon restarts, then the policy applies again
unless-stoppedRestartsRestarts unless you had stopped it by handStays stopped until you start it again, even across daemon restarts

In the test below, the demo stack used unless-stopped and a second project had no restart policy. The Docker daemon was then stopped and started again.

bash
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
Output
NAMES             STATUS
norestart-web-1   Exited (0) 12 seconds ago
demo-web-1        Up 8 seconds
demo-cache-1      Up 8 seconds (healthy)

The containers with a policy came back on their own and the other one did not. Docker applies a restart policy only after a container has stayed up for at least 10 seconds. This keeps the policy from restarting a container over and over when it fails right at startup. On Ubuntu and Debian the Docker service starts at boot by default. On other systemd distributions, enable it with the command below. This boot step was not run in the test sandbox, so it follows the Docker documentation.

bash
sudo systemctl enable docker.service containerd.service

Run systemctl is-enabled docker to check it. A result of enabled means the service will start at boot. It does not prove the containers will, so confirm their policy with docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' demo-web-1.

Docker Compose v1 vs v2 and the Version Key

Docker Compose v1 is the old Python tool run as docker-compose, while v2 and later run as the docker compose plugin written in Go.

Compose versions at a glance
Compose v1Compose v2Compose v5
Commanddocker-compose up -ddocker compose up -ddocker compose up -d
Written inPythonGoGo
Released2014Announced 20202025
StatusNo longer supported after June 2023Supported, works the same as v5Supported and current, used for this guide
Top level version: keyOften required, values 2.0 to 3.8Ignored with a warningIgnored with a warning

The Docker history page for Compose says v5 works the same way as v2 and adds an official Go SDK, and that the number skipped to 5 to avoid confusion with the old file format versions 2 and 3. The docker compose command stays the same. The Compose CLI version, the Compose file specification and the Docker Engine version are three separate things.

On a fresh Ubuntu 24.04 install with only the plugin, the old command does not exist.

Output
docker-compose: command not found

Type docker compose with a space instead. Most old tutorials work after that change. A file that still starts with version: "3.8" runs too, with this warning.

Output
level=warning msg="/root/w/compose-up-d/norestart/compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"

Delete the version: line to silence it. Compose always validates the file against the current Compose Specification, whatever that line says.

Common docker compose up -d Errors

Most common docker compose up -d errors come from the daemon, a busy port, the file or the image, and the message says which.

Every message in this table was produced on the test machine. The fix column says what to check first.

docker compose up -d errors and fixes
MessageLikely causeFix
failed to connect to the docker API at unix:///var/run/docker.sockThe Docker daemon is not runningRun sudo systemctl status docker, then sudo systemctl start docker, and read sudo journalctl -u docker.service -n 50 --no-pager if it fails to start
permission denied while trying to connect to the docker APIYour user cannot use the socketUse sudo, or add the user to the docker group and log in again
Bind for 0.0.0.0:8088 failed: port is already allocatedAnother container or program holds the host portFind it with the commands below, then change the left side of ports:
no configuration file provided: not foundNo Compose file in the current foldercd to the project folder or use -f path/to/compose.yaml
did not find expected keyA YAML indentation mistakeFix the indentation at the line given, then run docker compose config
pull access denied ... repository does not exist or may require docker loginWrong image name or a private imageCheck the name and tag, or run docker login for that registry
429 Too Many RequestsDocker Hub pull rate limit reachedWait, log in to Docker Hub or use your own registry mirror
Found orphan containersA service was removed or renamed in the fileRun docker compose up -d --remove-orphans

Find What Holds a Port

To find what holds a port, ask Docker for containers publishing it, then ask the kernel for any listening process.

bash
docker ps --filter publish=8088 --format 'table {{.Names}}\t{{.Ports}}'
ss -ltnp 'sport = :8088'
Output
NAMES        PORTS
demo-web-1   0.0.0.0:8088->80/tcp
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      4096         0.0.0.0:8088      0.0.0.0:*    users:(("docker-proxy",pid=2143,fd=9))

The header line is shown exactly as ss printed it, with its last two column names run together. The sport filter matches the exact port number, so 18088 or 8089 cannot sneak into the result. A docker-proxy process shows that Docker is publishing the port, and the docker ps line above names the container that holds it. For a UDP service, swap -ltnp for -lunp.

When a Container Is Running but Unhealthy

When a container is running but unhealthy, its health check fails while the process stays up, and Docker reports it without restarting it.

This test service had restart: unless-stopped and a health check pointed at a port nothing listens on.

bash
docker compose ps --format 'table {{.Service}}\t{{.Status}}'
docker inspect --format '{{.State.Health.Status}} streak={{.State.Health.FailingStreak}} restarts={{.RestartCount}}' sick-api-1
docker inspect --format '{{(index .State.Health.Log 0).Output}}' sick-api-1
Output
SERVICE   STATUS
api       Up 15 seconds (unhealthy)
unhealthy streak=4 restarts=0
wget: can't connect to remote host (127.0.0.1): Connection refused

The restart count stayed at 0, because restart policies react to a container that exits, not to a failed health check. The health log shows the exact error of the check. docker compose up -d --wait on this stack ended with container sick-api-1 is unhealthy and exit code 1, so a deploy script would catch it.

When the Container Starts and Then Stops

When a container starts and then stops, docker compose ps -a shows the exit code and docker compose logs shows the reason.

An exit code of 1 is usually an app error such as a missing variable. 137 means the process was killed, often by the out of memory killer. 0 means the main process simply finished, which is normal for one off jobs but a sign of a wrong command for a server. Run docker compose config to see the final file after variables are filled in.

Running Docker Compose on a VPS Safely

Running Docker Compose on a VPS safely means publishing only the ports you need, because published ports skip ufw rules.

Docker writes its own firewall rules, and its documentation explains that traffic to a published port is diverted before ufw sees it. A ufw deny 8088 does not close a port that Compose published. For admin panels and databases, publish on the loopback address only.

yaml
ports:
  - "127.0.0.1:8088:80"
Output
SERVICE   PORTS
cache     6379/tcp
web       127.0.0.1:8088->80/tcp

Now only the server itself can reach port 8088, and a reverse proxy or an SSH tunnel brings it to you. Services that talk to each other, like web and cache here, need no published port at all, because they reach each other by service name on the project network.

This limits who can connect. It does not replace passwords, updates or TLS on the app that is exposed. For a full real world example, see how to self host n8n with Docker Compose behind a reverse proxy. A Docker VPS with root access lets you run the stack, set the firewall and keep it running with the restart policies above.

Questions people ask

What does -d mean in docker compose up?

-d means detached. It is short for --detach and runs the containers in the background, so the command returns your prompt instead of showing logs.

What does docker compose up do?

It creates and starts the services in your Compose file, with the networks and volumes they need. Depending on image, build and pull_policy, it pulls or builds images when needed, then starts containers in dependency order.

Does docker compose up -d pull the latest image?

Not reliably. Under the default missing policy cached images are normally reused, though the spec says latest is always pulled. Run docker compose pull first, or use up -d --pull always.

How do I see logs after docker compose up -d?

Run docker compose logs -f in the project folder. Add a service name to filter, and --tail 50 to start from the last 50 lines.

What is the difference between up -d and up -d --build?

The --build flag rebuilds images from your Dockerfile before starting, using the cache. Without it, an existing image is reused even if your code changed.

Why is docker compose up not working?

Read the error line first. The usual causes are a stopped daemon, a port already in use, a YAML mistake, a wrong image name or a missing Compose file in the folder.

Will docker compose up -d start my containers after a reboot?

Only with a restart policy such as restart: unless-stopped and a Docker service that starts at boot. The -d flag alone does not do it.

What is the difference between docker-compose and docker compose?

docker-compose is the old v1 Python tool, unsupported since mid 2023. docker compose is the current plugin and takes the same subcommands.

Sources

  1. Docker Docs, docker compose up reference
  2. Docker Docs, docker compose down reference
  3. Docker Docs, Compose FAQ
  4. Docker Docs, History and development of Docker Compose
  5. Docker Docs, Version and name top level elements
  6. Compose Specification, container attributes including pull_policy
  7. Docker Docs, Start containers automatically
  8. Docker Docs, Linux post installation steps for Docker Engine
  9. Docker Blog, Docker Compose what is new and the V1 deprecation

Written and tested by VPS Lane EngineeringWe run every step on real servers before publishing and update the guide when the software changes.