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

Kill Docker container if x11 window was closed #68

Closed
sandrokeil opened this issue Jul 18, 2018 · 2 comments
Closed

Kill Docker container if x11 window was closed #68

sandrokeil opened this issue Jul 18, 2018 · 2 comments

Comments

@sandrokeil
Copy link
Contributor

I've encountered some issues, mostly with Chromium, that the Docker container is still running if I close the browser. Not all chromium processes are killed on closing the Browser.

Is it possible to check, if the x11 window/session was closed and the Docker container is still running? Does it makes sense to kill the Docker container if no x11 session exists anymore?

@mviereck
Copy link
Owner

mviereck commented Jul 18, 2018

x11docker already terminates docker container if the additional X server is closed. Also, the X server is terminated if the container terminates.

If chromium does not terminate itself after closing chromium window, I'd call that a chromium bug.
Windowed applications should terminate themself if their windows are closed.

If a process is running with --hostdisplay, I see no way to decide if x11docker should terminate the container. For other X server options x11docker could check e.g. the output of xwininfo -root -children if there is any open window. But a process may close all windows and open another one after some delay. x11docker should not decide to terminate only because the container currently does not use it obviously.

If you run chromium e.g. with --xephyr or --weston-xwayland, x11docker will terminate the container if you close the X server window.

You could run a watching background process in ENTRYPOINT that terminates all chromium processes if xwininfo -root -children does not show a chromium window. Be aware that with --hostdisplay a chromium window from host would show up in xwininfo, too.

Alternatively, you can run e.g. docker stop containername if you want to stop chromium. That will terminate x11docker, too.

@mviereck mviereck changed the title Kill Docker container if x11 window/session was closed Kill Docker container if x11 window was closed Jul 19, 2018
@mviereck
Copy link
Owner

x11docker has a new option --checkwindow that adresses this issue:

     --checkwindow [=ARG]  Run container until all X windows are closed.
                       If ARG is provided, run container as long as 'grep' can
                       find ARG in output of 'xwininfo -root -children'.
                       This option helps to keep alive containers with
                       self-forking applications like gnome-terminal
                       or to stop endless running ones like chromium.

With additional X servers it is enough to just set --checkwindow.
In your case using --hostdisplay with chromium something like --checkwindow=Chromium should work, if keyword Chromium appears in all chromium windows.

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

No branches or pull requests

2 participants