Applies to: the Docker Compose plugin (docker compose), tested with Compose v2.40.3 on Docker Engine 29.1.3; the options are the same in the current Compose v5 reference

Run docker compose logs in the folder that holds your compose.yaml to see the output of every service in the project. Add a service name to see one service, -f to follow new lines live and --tail 50 to start with only the last 50 lines:

docker compose logs -f --tail 50 web

Press Ctrl+C to stop following. This only stops the log view; the containers keep running.

What the output looks like

Each line starts with the container name, so you can tell the services apart:

$ docker compose logs --tail 1 web worker
web-1  | 127.0.0.1 - - [30/Sep/2026:03:17:12 +0000] "GET /missing HTTP/1.1" 404 153 "-" "Wget" "-"
worker-1  | job 88 done

Compose shows what the container wrote to both standard output and standard error. In our test, a worker that printed warnings to stderr showed them in docker compose logs, and they still appeared when we sent the command’s own stderr to /dev/null, so you can pipe everything to grep:

docker compose logs --no-color web | grep ' 404 '

Useful options

  • -f or --follow: keep printing new lines as they arrive.
  • -n 100 or --tail 100: only the last 100 lines of each container. The default is all, which can be a lot on a service that has run for weeks.
  • --since 10m: only lines from the last 10 minutes. You can also give an exact time in UTC as YYYY-MM-DDTHH:MM:SSZ.
  • --until 1h: only lines older than one hour (or before a given time). Combine it with --since to cut out a window.
  • -t or --timestamps: add Docker’s own timestamp to each line, useful when the application doesn’t print one.
  • --no-log-prefix: drop the web-1 | prefix, handy when you save a log to a file.
  • --no-color: plain output without colour codes.
  • --index 2: for a service scaled to several replicas, show only the second container.

For example, timestamps on the last two lines:

$ docker compose logs -t --tail 2 worker
worker-1  | 2026-09-30T03:17:17.425321294Z job 7 done
worker-1  | 2026-09-30T03:17:17.425374044Z warning: queue slow

Running it from another folder

Outside the project folder Compose can’t find the project:

$ docker compose logs
no configuration file provided: not found

Either point to the file or use the project name (docker compose ls lists the running projects):

docker compose -f /opt/app/compose.yaml logs web
docker compose -p app logs web

A wrong service name gives no such service: nosuch; check the names under services: in the file. You can also read one container directly with docker logs, using the full container name, for example docker logs --tail 20 app-web-1. Listing your containers shows the names.

Logs of stopped and removed containers

After docker compose stop, the logs are still there and docker compose logs shows them, which helps when a service crashed. After docker compose down the containers are removed and their logs go with them: in our test, docker compose logs printed nothing afterwards. Save what you need before you run down:

docker compose logs --no-color --no-log-prefix web > web.log

Where the logs are stored and how to limit their size

With the default json-file logging driver, each container’s log is a file under /var/lib/docker/containers/<id>/. docker inspect app-web-1 | grep LogPath prints the exact path. According to Docker, json-file doesn’t rotate logs by default (max-size defaults to unlimited), so a chatty service can fill the disk over time. Set a limit per service in compose.yaml:

services:
  web:
    image: nginx:alpine
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

This keeps at most three files of 10 MB each. To set a default for all new containers on the server, put the same settings in /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Then restart Docker (sudo systemctl restart docker). Docker notes that existing containers keep their old settings: recreate them with docker compose up -d --force-recreate. Docker also recommends the local driver, which rotates by default. If a server is already short of space, find the largest directories first.

New to Compose? Start with Docker Compose basics.

Official documentation: docker compose logs and JSON file logging driver.

Ucartz services for this topic

  • KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
  • Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
  • Hire an expert: engineers per 15 minutes, per hour or per month, with no contract.
Was this answer helpful? 0 Users Found This Useful (0 Votes)