Install VcXsrv and add the following to your Dockerfile.
Command to add to Dockerfile
ENV DISPLAY host.docker.internal:0.0 RUN apt-get install openjfx
I want to run a JavaFX application inside a Docker container!
I think many people think so. I am one of them.
At that time, I ran into some problems.
Here we will solve the above problem.
You need to install the openjfx package.
Since Java 9, which was split into Oracle JDK and OpenJDK, OpenJDK no longer includes JavaFX packages. Originally, the openjdk package and openjfx package should be introduced in Sarah's base image, but the base image published by openjdk does not include the openjfx package.
The following description is required in the Dockerfile.
Install the openjfx package
RUN apt-get install openjfx
If you want to write it neatly, you should write it as follows.
Cleanly install the openjfx package
RUN apt-get update && \ apt-get install -y --no-install-recommends \ openjfx \ && \ rm -rf /var/lib/apt/lists/*
OpenJFX can not be used anymore · Issue #323 · docker-library/openjdk https://github.com/docker-library/openjdk/issues/323
rburgst/java8-openjfx-docker: openjdk8 container including openjfx https://github.com/rburgst/java8-openjfx-docker
The screen inside the container is displayed only inside the container. This means that it is usually impossible to see from outside the container.
But that's Docker, it's not doing nothing. There is a method to output the GUI screen inside the container to the outside of the container.
For details, refer to the following web page.
This software is like an X-Server emulator and can display WSL GUI apps.
Display Linux GUI on Win10 with WSL and VcXsrv https://www.usagi1975.com/201903021706/
The environment variable DISPLAY is the output destination of the GUI screen displayed by the x window system inside the container.
Let's set this to
Setting the environment variable DISPLAY
ENV DISPLAY host.docker.internal:0.0
Run GUI app inside Docker for windows container --FILES = 0 https://fileszero.kimurak.net/2019-04-18-docker-and-gui-on-windows/
DISPLAY-What are you going to do? https://sites.google.com/site/teyasn001/ubuntu-12-10/huan-jing-bian-shudisplay
Fly windows from local to remote X server-Qiita https://qiita.com/kkk627/items/8db34266722488eae412
In summary, the mechanism is as follows.
The JavaFX app I created is made by Gradle, so it will be as follows.
FROM gradle:5.5-jdk11 ENV DISPLAY host.docker.internal:0.0 RUN apt-get update && \ apt-get install -y --no-install-recommends \ openjfx \ && \ rm -rf /var/lib/apt/lists/* RUN git clone https://github.com/morichan/retuss.git WORKDIR retuss RUN gradle build CMD ["gradle", "run"]
Please refer to it.
docker-images/retuss-docker at master · Morichan/docker-images https://github.com/Morichan/docker-images/tree/master/retuss-docker
Morichan/Retuss: Real-time Ensure Traceability between UML and Source-code System https://github.com/Morichan/Retuss