Skip to content

[BUG] Watch mode: Deleting files doesn't restart services which have already exited #13057

@dkaste

Description

@dkaste

Description

If my container exits early (e.g. due to a compile error), file delete events don't properly trigger a sync+restart. Instead I get this error message:

WARN[0232] Error handling changed files: 1 error occurred:
        * deleting paths in 2996dfdb5771fe1f20cc98f25dea0fc876fe5be79b9932f2c26ee24036323b3f: Error response from daemon: container 2996dfdb5771fe1f20cc98f25dea0fc876fe5be79b9932f2c26ee24036323b3f is not running

Interestingly, file change events work just fine, as do delete events while the container is still running.

Steps To Reproduce

services:
  test1:
    image: debian
    command: sh -c 'while true; do sleep 2; done'
  test2:
    image: debian
    command: echo "hello"
    develop:
      watch:
        - path: .
          target: /
          action: sync+restart
touch dummy.txt
docker compose up --watch

In another shell:

rm dummy.txt

Back in the original shell you should see an error message similar to the one above, instead of the container being restarted and printing "hello" as expected.

Compose Version

v2.38.2

Docker Environment

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

Server:
 Containers: 4
  Running: 3
  Paused: 0
  Stopped: 1
 Images: 5
 Server Version: 28.3.2
 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
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 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.15.5-200.fc42.x86_64
 Operating System: Fedora Linux 42 (Workstation Edition)
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.95GiB
 Name: jupiter
 ID: 821b19f5-dabc-4982-814b-7ec792078a06
 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

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions