Skip to content

[BUG] compose up --watch rebuilds attach to logs after the container is running #12839

Open
@robinhickmann

Description

@robinhickmann

Description

Usually when you run docker compose up, it creates and runs your containers, while showing you some nice logs (unless you use -d). When you use watch, with the rebuild action, it attaches to logs differently sometime after it's running, causing it to not display any startup logs. It's worth noting that it does still print logs, just not the first few milliseconds.

Steps To Reproduce

  1. Example code

The comment is for triggering watch

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)

        fmt.Println("Hello, World!")

	<-sigChan
}

// test
  1. Example mod file
module hello

go 1.24.2
  1. Example Dockerfile
FROM golang:alpine

WORKDIR /app

COPY . .

RUN go build -o hello .

CMD ["./hello"]
  1. Example compose file
services:
  hello:
    build:
      context: .
      dockerfile: Dockerfile
    develop:
      watch:
        - path: .
          action: rebuild
  1. Run docker compose up --watch

  2. Edit the comment in the example, or just trigger watch a different way.

It prints "Hello, World!" when you first run the command, but after it rebuilds with watch, it doesn't print.

Compose Version

Docker Compose version v2.35.1

Docker Environment

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

Server:
 Containers: 20
  Running: 2
  Paused: 0
  Stopped: 18
 Images: 91
 Server Version: 28.1.1
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.14.4-200.fc41.x86_64
 Operating System: Fedora Linux 41 (Workstation Edition)
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.26GiB
 Name: nzxt-pc
 ID: 243ae51b-a1fb-4b73-a42d-ef8cb1420620
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 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