I am having trouble hosting my JavaFX GUI application on a docker container. My JavaFX GUI application is in a single executable jar file: start.jar
This is my dockerfile:
FROM openjdk:11-jre-slim
RUN mkdir logs
RUN apt-get update && apt-get install libgtk-3-0 libglu1-mesa xvfb -y && apt-get update
RUN apt-get install xvfb
COPY library/javafx-sdk-11.0.2 javafx-sdk-11.0.2
COPY start.jar start.jar
ENV DISPLAY=:99
COPY run.sh /run.sh
RUN chmod a+x /run.sh
CMD /run.sh
And run.sh
:
#!/bin/bash
rm /tmp/.X99-lock #needed when docker container is restarted
Xvfb :99 -screen 0 640x480x8 -nolisten tcp &
java --module-path javafx-sdk-11.0.2 -jar start.jar
When I run my start.jar
application, I get this error:
ES2 Prism: Error - GLX extension is not supported
GLX version 1.3 or higher is required
How can I update to the correct GLX version so I can successfully run my JavaFX GUI application on docker?
You could try disabling the hardware graphics acceleration dependency, by setting a software pipeline for Prism
. This can be done by setting the param -Dprism.order=sw
.
So the java command inside run.sh
should change to:
#!/bin/bash
rm /tmp/.X99-lock #needed when docker container is restarted
Xvfb :99 -screen 0 640x480x8 -nolisten tcp &
java -Dprism.order=sw --module-path javafx-sdk-11.0.2-jar start.jar