Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce docker exec kill #35703

Open
ndeloof opened this issue Dec 5, 2017 · 4 comments · May be fixed by #41548
Open

introduce docker exec kill #35703

ndeloof opened this issue Dec 5, 2017 · 4 comments · May be fixed by #41548
Labels
area/runtime kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@ndeloof
Copy link
Contributor

ndeloof commented Dec 5, 2017

Description

One can start additional processes in a container with exec API, one can inspect their status using exec/{id}/json, but one can't kill such a process.
I suggest an API is introduced for this purpose, /exec/{id}/stop + /exec/{id}/kill to mimic the equivalent for container's PID 1.

@thaJeztah thaJeztah added area/runtime kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny labels Dec 6, 2017
@thaJeztah
Copy link
Member

/cc @tonistiigi @crosbymichael

@dtaniwaki
Copy link

I'd like to take this issue and will send a pull request.

@awesomebytes
Copy link

awesomebytes commented Sep 29, 2020

Hello,

I would like to ask if this issue includes my current issue (and if the proposed implementation takes care of it): When I add another process with docker exec and I send a SIGTERM or SIGINT signal to that docker exec, it terminates (SIGKILL) instead of forwarding the signal to the docker exec-ed command to cleanly exit the process. Example:

# Shell 1: Run a long-running process in a container
docker run --rm -t --name exec_signal_problem python:3 sleep 999

# Shell 2: Run another process that I would like to run for a while but be able to stop it cleanly
# Here I run a Python interpreter that will catch SIGTERM signals printing them
docker exec exec_signal_problem python -c "import signal;signal.signal(signal.SIGTERM, print);import time; time.sleep(600)"

# Shell 3: kill the docker exec process
ps aux | grep "docker exec exec_signal_problem" | grep -v grep | awk '{print $2}' | xargs kill -s SIGTERM

My expected behavior and output would be that Shell 2 would print the SIGTERM signal received, such as:

15 <frame object at 0x7f2c84765050>

But instead, the process in Shell 2 is killed with SIGKILL and I get the output:

Terminated

Note that the process has been effectively killed (I've read other issues while googling what is going on of people finding their processes still running).

In case it matters, my use-case includes having one docker container running (with a main command, usually a driver for a device) and running multiple commands via docker exec in it during the time it's running (scripts that communicate with the driver and should not die without releasing resources cleanly first).
I guess I'll make workaround scripts that find the process that was docker exec-ed and kills it for now, but it would be very nice if docker would support this use-case.

Also thanks a lot for your great work.

Edit: My docker version reports:

Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:02:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:01:06 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@awesomebytes
Copy link

Adding here a comment to link to the workaround I made in order to support killing a command that was docker exec-ed: #9098 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants