Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Ctrl+C terminate attached container but not docker compose execution #1447

Closed
luislavena opened this issue Mar 19, 2021 · 2 comments · Fixed by #1451
Closed

Ctrl+C terminate attached container but not docker compose execution #1447

luislavena opened this issue Mar 19, 2021 · 2 comments · Fixed by #1451
Assignees
Labels
bug 🐞 App is not working correctly. compatibility Compatibility with docker-compose

Comments

@luislavena
Copy link

Description

Hello folks,

It appears that compose-cli (docker compose) do not terminate execution when hitting Ctrl+C on an attached controller. This behavior is not reproducible compared to docker-compose exact same setup.

I originally thought this could be an issue with WSL2 (not using Docker Desktop for Windows) so decided to compare with a real Ubuntu 20.04 machine and the issue is the same.

Hope was able to provide all the details, but please let me know if additional tests are required.

Thank you for creating Docker and this new compose CLI!!! ❤️ ❤️ ❤️

Cheers.

Steps to reproduce the issue:

  1. Create simple docker-compose.yml file with sleep infinity container (see below)
  2. Run docker compose up and wait for Attaching notification
  3. Press Ctrl+C and wait for Stopped notification

Describe the results you received:

Notice that command does not exit (and requires kill)

Describe the results you expected:

Expected the process to terminate in similar way as docker-compose execution.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: 1.0.10
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:18:20 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:16:15 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

❯ docker context inspect default
[
    {
        "Name": "default",
        "Metadata": {
            "StackOrchestrator": "swarm"
        },
        "Endpoints": {
            "docker": {
                "Host": "unix:///var/run/docker.sock",
                "SkipTLSVerify": false
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "\u003cIN MEMORY\u003e",
            "TLSPath": "\u003cIN MEMORY\u003e"
        }
    }
]

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 2
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 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: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.4.91-microsoft-standard-WSL2
 Operating System: Ubuntu 20.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 3.84GiB
 Name: Nostromo
 ID: RY5L:CILO:ER4Z:ZKX3:WXDZ:RRPN:3CGP:UWJJ:6JAJ:RS6A:MQGT:2YPO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS ECS, Azure ACI, local, etc.):

Output of docker-compose version:

docker-compose version 1.28.5, build c4eb3a1f
docker-py version: 4.4.4
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Content of docker-compose.yml:

---
version: "3.8"

services:
  infinity:
    image: alpine:latest
    command: sleep infinity

docker events for docker-compose up:

2021-03-19T19:14:04.705856800-03:00 network create 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (name=tmp_default, type=bridge)
2021-03-19T19:14:04.836492600-03:00 container create 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:14:04.846123900-03:00 container attach 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:14:04.868132500-03:00 network disconnect 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (container=5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9, name=tmp_default, type=bridge)
2021-03-19T19:14:04.918869800-03:00 network connect 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (container=5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9, name=tmp_default, type=bridge)
2021-03-19T19:14:05.334706000-03:00 container start 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:14:11.472980100-03:00 container kill 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1, signal=15)
2021-03-19T19:14:21.532519800-03:00 container kill 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1, signal=9)
2021-03-19T19:14:21.554751300-03:00 container die 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, exitCode=137, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:14:21.708538600-03:00 network disconnect 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (container=5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9, name=tmp_default, type=bridge)
2021-03-19T19:14:21.739092400-03:00 container stop 5195bab8d6050067cb43f5c97a0c231184d3d818aa00dd0f5d2e6f95ed6b10b9 (com.docker.compose.config-hash=fc8d5a95d51343de88fbfce31f3992d3f19291febe02bfaed2cc486a4523694c, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.28.5, image=alpine:latest, name=tmp_infinity_1)

docker events for docker compose up:

2021-03-19T19:15:10.945851500-03:00 container create e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:15:10.961870400-03:00 container attach e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:15:10.996067100-03:00 network connect 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (container=e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75, name=tmp_default, type=bridge)
2021-03-19T19:15:11.395854700-03:00 container start e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:15:21.902519800-03:00 container kill e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1, signal=15)
2021-03-19T19:15:31.958975600-03:00 container kill e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1, signal=9)
2021-03-19T19:15:31.979749900-03:00 container die e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, exitCode=137, image=alpine:latest, name=tmp_infinity_1)
2021-03-19T19:15:32.163355400-03:00 network disconnect 2a86d6d216cd16d1b8803dcded3d219cc48aadbc6bef51f9605a9f791ec67858 (container=e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75, name=tmp_default, type=bridge)
2021-03-19T19:15:32.197542000-03:00 container stop e884e2fdae17dffb32b8d3177e8018a86678a8507ea31d5f895a72185f3baf75 (com.docker.compose.config-hash=sha256:cb1ebe4f170a59a7b4bf8d111b50a2752a9d1df7136e8773108c036734fb3beb, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=tmp, com.docker.compose.project.config_files=/tmp/docker-compose.yml, com.docker.compose.project.working_dir=/tmp, com.docker.compose.service=infinity, com.docker.compose.version=1.0-alpha, image=alpine:latest, name=tmp_infinity_1)
@ndeloof ndeloof added compatibility Compatibility with docker-compose compose labels Mar 20, 2021
@dop251
Copy link

dop251 commented Mar 21, 2021

Same here. Looks like it broke in the very last release (1.0.9 was fine). I'm also seeing these messages in the console after pressing Ctrl-C:

^CGracefully stopping...
WARNING Unexpected API error for <container_name> : context canceled 
WARNING Unexpected API error for <container_name> : context canceled 

Doing strace on the hung docker compose up process shows it's waiting on a futex. The only way to make it exit is using kill -9.

@ndeloof ndeloof self-assigned this Mar 22, 2021
@ndeloof ndeloof added the bug 🐞 App is not working correctly. label Mar 22, 2021
@ndeloof ndeloof mentioned this issue Mar 22, 2021
@luislavena
Copy link
Author

Thank you @ndeloof, I can confirm this is working great with 1.0.12 release!

❤️ ❤️ ❤️

Have a great week!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐞 App is not working correctly. compatibility Compatibility with docker-compose
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants