Skip to content

exec does not (always) forward signals to container process #2607

Description

@reitzig

As a CLI user, I want container processes to be interrupted if I interrupt their attached "parent" docker exec from the calling shell so I don't leave rogue processes around.

Steps to reproduce the issue:

# Given
docker run -d --rm --name mwe ubuntu sleep 1000
# When
docker exec mwe tail -f /dev/null # Ctrl+C# Then
[[ $(docker exec mwe ps -e | grep -c tail)-eq 0 ]]

Describe the results you received:

failure ( echo $? --> 1 )

Describe the results you expected:

success ( echo $? --> 0 )

Additional information:

  • Reproduces with either -i or -t.

  • Does not reproduce with -it.

  • Interestingly, does not reproduce when run like so:

    docker exec mwe tail -f /dev/null &kill -s SIGINT $!
  • But does reproduce when sending the signal from Go via cmd.Process.Signal (see here) (unless -t is passed to docker exec).

  • While -it is a workaround in some situations, it is not always possible (build servers, tests, ...).

Output of docker version:

Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:07 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

Output of docker info:

Client:
Debug Mode: false
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 17
Server Version: 19.03.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
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
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.3.0-46-generic
Operating System: Ubuntu 18.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 23.26GiB
Name: tailchaser
ID: NYXA:VM6T:PP6Z:LY57:2D2O:CZGZ:2MXO:SW5S:6HKV:DDWJ:2XLA:QD3P
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
WARNING: No swap limit support

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