mindm49907
mindm49907

Reputation: 278

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.

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!

Upvotes: 1

Views: 2599

Answers (2)

Jan Suchotzki
Jan Suchotzki

Reputation: 1426

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.

Upvotes: 2

JohnIV
JohnIV

Reputation: 189

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.

Upvotes: 0

Related Questions