Run graphical process in Docker container, detach and reconnect to the running GUI

Let’s say I have some computations in Python that take a long time, and are run from the Spyder IDE so the results can be easily inspected and used for further work afterwards.

I want to run the Spyder process inside a Docker container that is hosted on a server machine (i. e. not the same machine I’m sitting in front of). I have already seen that it is possible to run e. g. LibreOffice and Chrome like that, so this should be possible. But these processes were not kept alive when the user detached from the container.

  • Pulling image from local docker registry: download completed, but image not found
  • Ansible docker_container command failing with no output
  • How to customize the docker gcc command and add own path instead of /usr/src
  • Docker Entry Point with Script Arguments
  • Docker API version with Docker login in CentOS 7
  • How to map a virtual host to a container in docker?
  • Now the question is: is there a way to open a Spyder process within a Docker container, start the computations manually, detach from the Docker container, and afterwards reconnect to the container so I return to the still running Spyder GUI to be able to inspect the outcome of the computations and keep working with them?

    To keep it simple for the users (which would be multiple people, but each with their own container), I would not want to have to save the computation results to a file a re-read them for further processing.

    With IPython, I could probably simply use screen to keep the interpreter alive. But I would not know how to achieve the same thing with Spyder. Can I maybe somehow “connect” Spyder to a remote IPython interpreter?

    The solution:

    Thanks to @JanSuchotzki, I was able to get a X11-VNC-server-container running alongside a client container where Spyder is installed and that can use the server container for displaying graphics. After additionally setting an environmental variable USER, I’m able to run Spyder successfully. Only the screen size of the X11-server needs to be adjusted not to cut off the edge of the Spyder GUI, then everything works great!

  • Docker + Virtual Box = VT-x is not available (VERR_VMX_NO_VMX)
  • How to enable influx http authentication flag in docker container
  • How to measure containers start-up and end time from some API?
  • Is it redundant in a Dockfile to run USER root since you're already root?
  • Service from sources inside Docker container
  • Execute command on host during docker build
  • 2 Solutions collect form web for “Run graphical process in Docker container, detach and reconnect to the running GUI”

    When running on a remote machine you might want to go with something like VNC. That basically means your container running Spyder also serves as a VNC-Server. Now you can attach via VNC-Client to the container and check what the current state is (interact with your IDE).

    This will also work in a multi-user setup assuming each container, or better to say the VNC-server running inside, works on another port. Then you can simply distinguish the different containers by port.

    I have created a base-image for running an debian based container with X-Server and VNC-Server. You can have a look on my Docker-Hub Account. There you will find an image for client and for server.

    I’m not familiar with Sypder, but I think you’ll want to start by looking at the Docker docs regarding networking and exec.

    Another thought: If you can tell Spyder to run as a server, you could connect a client via an exposed port.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.