Skip to content

[BUG] docker compose -p <Project> logs -f not showing logs of later started containers #10618

@makon

Description

@makon

Description

docker compose -p <project> logs -f shows only log entries of already running containers.
It does not show any entries of later started containers in the same --project-name.

Doing it without the --project-name flag with docker compose logs -f it works as expected.
It even works with the name attribute in the docker-compose.yml.
It worked with Docker Compose v1.

docker-compose.yml:

# name: test

services:
  hello:
    image: ubuntu
    command:
      [
        "/bin/bash",
        "-c",
        "while sleep 1; do echo 'Hello'; done"
      ]

  world:
    image: ubuntu
    command:
      [
        "/bin/bash",
        "-c",
        "while sleep 1; do echo 'World'; done"
      ]

Steps To Reproduce

  1. use the docker-compose.yml
  2. run in a terminal docker compose -p test up -d hello
  3. run in another terminal docker compose -p test logs -f
  4. wait 10 seconds
  5. run in a terminal docker compose -p test up -d world
  6. the logging terminal shows only hello entries and no world entries

Compose Version

Docker Compose version v2.18.1

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 7
  Paused: 0
  Stopped: 11
 Images: 58
 Server Version: 24.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.19.0-42-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Live Restore Enabled: false

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions