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

feature request: stop an exec_run #3155

Open
rrauenza opened this issue Jul 6, 2023 · 1 comment
Open

feature request: stop an exec_run #3155

rrauenza opened this issue Jul 6, 2023 · 1 comment

Comments

@rrauenza
Copy link

rrauenza commented Jul 6, 2023

I have a use case where I need to stop an exec_run after starting it over an api. I'm implementing something similar to a healthcheck, but externally, and I need to timeout the healthcheck.

Workarounds would be to use /usr/bin/timeout as part of the exec command or just use /usr/bin/docker exec and kill the process, but it would also be nice to have a way to stop an exec that was started from the api.

edit: reading over moby/moby#9098 ...I need to look and see if my assumptions about killing a docker exec killing the underlying exec.

edit2: WELL... ^C'ing an exec does NOT stop the actual exec. Just the docker process monitoring it.

@rrauenza
Copy link
Author

rrauenza commented Jul 6, 2023

It looks like the Pid is included in the inspect, so it may be possible to kill the exec by issuing another exec in the container:

ex2 = container.client.api.exec_inspect(ex['Id'])
ex2
{'ID': '28bc2ec956ddf05e63ce0b5a8e62a87ac73d6c0e2a87a97ae364a6906c6a67c8', 'Running': True, 'ExitCode': None, 'ProcessConfig': {'tty': False, 'entrypoint': '/bin/sleep', 'arguments': ['1000'], 'privileged': False}, 'OpenStdin': False, 'OpenStderr': True, 'OpenStdout': True, 'CanRemove': False, 'ContainerID': '8087ec8e5d1594e55b0282233ac48a1d7e576523010c5719e3236df5bb524622', 'DetachKeys': '', 'Pid': 25055}

But the pid is the outside pid of the process, not the internal. Which has a problem if managing from within another docker container, or if the manager is not root, but the process is running as root inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant