Skip to content

v2 docker compose kill errors when the container is not running, where v1 was not #8864

@majkelcc

Description

@majkelcc

Description

When I send a kill signal to a container that is stopped using docker compose kill ..., the command exits with an error. This was not the case with docker-compose v1.

Steps to reproduce the issue:

  1. With the following example docker-compose.yml file:
---
services:
  hello:
    image: hello-world
  1. Run docker compose up -d hello
  2. Run docker compose stop hello
  3. Run docker compose kill hello

Describe the results you received:

Sending a kill signal results in the following error with an exit status 1:

[+] Running 0/0
 ⠿ Container hello-1  Error while Killing                                                                                            0.0s
Error response from daemon: Cannot kill container: c966210d3f9f5267d8b60a4b6c77ed92e2bc4ce49cbb46bbe7db022f5a2baba7: Container c966210d3f9f5267d8b60a4b6c77ed92e2bc4ce49cbb46bbe7db022f5a2baba7 is not running

Describe the results you expected:

This is a breaking change, which I haven't seen documented anywhere. I would expect the same behaviour as with docker-compose v1 - no error message and exit code 0. Alternatively, a way to achieve the same result (with a --force flag for example).

Output of docker compose version:

Docker Compose version v2.0.0 (Docker Desktop on Mac)
Docker Compose version v2.0.1 (Linux)

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.3)
  compose: Docker Compose (Docker Inc., v2.0.0)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 18
  Running: 3
  Paused: 0
  Stopped: 15
 Images: 16
 Server Version: 20.10.8
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e25210fe30a0a703442421b0f60afac609f950a3
 runc version: v1.0.1-0-g4144b63
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.47-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 3.841GiB
 Name: docker-desktop
 ID: TL4L:QGJR:PYW2:VLK5:NFLF:GEML:53W3:Y4GB:SU6T:HLG2:FIV4:3UD2
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Tested on Mac OS (Docker Desktop) and Linux with the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions