Ctrl K

Docker Compose Daily Workflow

Docker Compose commands on a Linux host for starting, entering, inspecting, and stopping services.

This workflow assumes the project is running through Docker Compose and compose.yaml is the entry point for the stack.

Start the stack

Navigate to the project folder first. Docker Compose always reads the compose.yaml in the current directory, so running commands from the wrong location will either fail or affect the wrong project.

cd ~/your-project

Start in detached mode, reusing existing images if available:

docker compose up -d
# -d: detach

Force a rebuild when Dockerfiles, dependencies, or package lockfiles have changed:

docker compose up -d --build

Check status and service names

Use docker compose ps to check the process status of containers that belong to the Compose project in the current directory.

docker compose ps
# ps: process status

The command is project scoped. It reads the Compose project from the current folder, usually compose.yaml, and shows only the containers managed by that Compose project.

Use docker compose config --services when you need the exact service names from the Compose file. These names are used with commands like exec, logs, restart, and stop.

docker compose config --services

Use docker ps when you need a system level view of all running containers on the Docker host, including containers started by other Compose projects.

docker ps
  • docker compose ps shows containers for the current Compose project.
  • docker ps shows all running containers globally on the Docker host.
  • Multiple Compose projects can run at the same time.
  • Host ports must be unique. For example, only one running container can bind host port 3306.
  • Container ports can be the same across containers because each container has its own network namespace.

Enter a container

Enter a running service container to work inside its environment. Commands run here use the container's tools, paths, and installed packages.

docker compose exec <service-name> bash

If bash is not available in the container, use sh instead:

docker compose exec <service-name> sh

Once inside, verify your location and check available files:

pwd
ls

Follow logs

Stream live output from a service without entering. Can be used to follow server output or to debug startup issues.

docker compose logs -f <service-name>

Stop the stack

Stop and remove containers and the compose network entirely:

docker compose down

Stop containers without removing them:

docker compose stop

Typical daily sequence

cd ~/your-project
docker compose up -d
docker compose ps
docker compose exec backend bash
docker compose exec frontend bash
  • After a reboot, containers do not restart automatically unless restart policies are configured.
  • docker compose exec requires the container to already be running.