Skip to content

Docker Compose Daily Workflow

This workflow assumes the project is running through Docker Compose and compose.yaml is the entry point for 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.

Terminal window
cd ~/your-project

Start in detached mode, reusing existing images if available:

Terminal window
docker compose up -d
# -d: detach

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

Terminal window
docker compose up -d --build

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

Terminal window
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.

Terminal window
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.

Terminal window
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 running service container to work inside its environment. Commands run here use the container’s tools, paths, and installed packages.

Terminal window
docker compose exec <service-name> bash

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

Terminal window
docker compose exec <service-name> sh

Once inside, verify your location and check available files:

Terminal window
pwd
ls

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

Terminal window
docker compose logs -f <service-name>

Stop and remove containers and the compose network entirely:

Terminal window
docker compose down

Stop containers without removing them:

Terminal window
docker compose stop
Terminal window
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.