Docker compatibility for Slideflow Studio
Feature
Compatibility and feature testing when running Slideflow Studio from Docker containers (as referenced in #240)
Additional context
GLFW OpenGL rendering and Tkinter both theoretically support Docker, so this should be possible to support.
Hi, I was able to launch slideflow studio on docker running:
xhost +
docker run -it --rm -e DISPLAY=:0.0 --network=host --privileged -v /dev:/dev -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/root/.Xauthority jamesdolezal/slideflow:latest-tf
And inside the container:
apt update
apt install python3-tk
Not sure if all the parameters are mandatory
Thank you for reporting this! That's great news. I'll update the dockerfiles to install python3-tk and include these instructions in the documentation.
To clarify, this should work with the following command:
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
jamesdolezal/slideflow:latest-tf
However, on some distributions, you may need to run the following (on the host machine, not in the container):
sudo apt-get install x11-xserver-utils
xhost +local:docker
You can also forward the display output over SSH with X11 forwarding. SSH using the -X flag:
ssh -X user@destination
Then start the docker image. When forwarding over SSH, I had to use different flags:
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v $HOME/.Xauthority:/root/.Xauthority \
--net=host \
jamesdolezal/slideflow:latest-tf
Hi, thank you for the great tool!
I'd like to launch Slideflow Studio on docker and access it from the client PC. I followed your instruction and run
slideflow-studio
, but I got the following error:
/usr/local/lib/python3.8/dist-packages/glfw/__init__.py:916: GLFWError: (65543) b'GLX: Failed to create context: BadValue (integer parameter out of range for operation)'
warnings.warn(message, GLFWError)
python3: /builds/florianrhiem/pyGLFW/glfw-3.3.8/src/window.c:530: glfwSetWindowPos: Assertion `window != ((void *)0)' failed.
Aborted (core dumped)
. The same error occurred when I ran
python -m slideflow.studio
How can I resolve this?
I'm looking forward to hear from you. Thank you.
It looks like GLFW (the window management library Studio uses) is having trouble finding an active X server. This is a common issue when attempting to run GUI applications in a Docker container.
The following additional details will help us look for a solution:
- What operating system is the container being run on?
- What command did you use to run the container?
- Is the container being run locally (on a machine with a display output), or remotely? If remotely, how is the display output being forwarded?
-
What operating system is the container being run on? -> Ubuntu 20.04.6 LTS or CentOS Linux 7 (I received the same error message on both operating systems).
-
What command did you use to run the container? ->
docker run -it --rm \
-e DISPLAY=$DISPLAY \
--net=host \
-v $HOME/.Xauthority:/root/.Xauthority \
-v /tmp/.X11-unix:/tmp/.X11-unix \
jamesdolezal/slideflow:latest-tf
- Is the container being run locally (on a machine with a display output), or remotely? If remotely, how is the display output being forwarded?
-> It is being run remotely. After logging in the remote server using
ssh -X user@destination, I confirmed thatDISPLAY=localhost:10.0was set. I also verified thatxeyeswas successfully forwarded remotely in the docker container.
Thank you.