Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

4 November 2026 · One command a day

How do I start a Docker Compose stack in the background on Linux?

The docker compose up -d command reads your compose file and starts every service in it in the background. It creates the containers, networks and volumes the file describes, then gives you your prompt back. Use it when you want a stack such as a web app and its database to keep running after you close your SSH session.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

cd /srv/appname
sudo docker compose up -d

First, cd into the folder that holds your compose.yaml (or docker-compose.yml), because Compose looks for the file in the current directory. sudo is needed unless your user is in the docker group. docker compose is the Compose v2 plugin, written with a space. The older docker-compose with a hyphen is the retired v1 tool. up creates anything that is missing and starts the services. It also recreates any container whose settings have changed since the last run. -d means detached: the containers run in the background and their logs do not fill your terminal.

What you will see

[+] Running 4/4
 ✔ Network appname_default    Created    0.1s
 ✔ Volume "appname_dbdata"    Created    0.0s
 ✔ Container appname-db-1     Started    0.7s
 ✔ Container appname-web-1    Started    1.1s

Each line is one thing Compose has dealt with. The first part of each name is the project name, which defaults to the folder name. The container names end in -1 because each service runs one copy. Created means it was made fresh. Started means the container is now running. On a second run you will see Running for containers that did not need to change. Containers are started in the order set by depends_on, so the database comes up before the web service. To check they are still up a minute later, see how to see which Docker containers are running.

When to use it

Watch out for

up -d does not rebuild images you build yourself. If a service uses build: and you have changed its code or Dockerfile, plain up -d keeps running the old image and nothing looks different. Run sudo docker compose up -d --build to rebuild first. Also, a container that crashes straight after starting still shows Started here, so if the site does not respond, follow the container's logs to see why.

Questions people ask

How do I stop the stack again?

From the same folder, run sudo docker compose down. It stops and removes the containers and the network but keeps named volumes, so your data stays unless you add -v.

Will the stack start again after a reboot?

Only if each service has a restart policy such as restart: unless-stopped in the compose file. The Docker service also has to be enabled, which it is by default on Ubuntu 24.04.

Running your own containers in the background like this needs a server you control, not shared hosting. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I keep a command running after I log out of Linux? · How do I fix file ownership on Linux after running something as root? · How do I see memory and CPU use per Docker container on Linux? · All daily notes