Docker and Javafx

I want to use docker compose watch on a javafx17 project in IntelliJ as well as run the resulting .jar in a docker container.
I need a working Dockerfile, docker-compose.yml and how to display the gui ("Xserver).
Any help appreciated.
The biggest problems seems to be accessing the jfx modules in the container

In Windows containers or in Linux Containers on Windows?

Also you know that Docker is not for Desktop applications, right? It is possible in Linux containers, but harder with Docker Desktop, and not possible in Windows containers.

Hmmmmm
The pet-clinic example referred to in the docs works perfectly.
How bout Linux Containers on WIndows

What pet-clinic example?

Web UI of course always works, but for containerizing desktop applications there are other ways designed exactly for that even if it can work with Docker. But you chose the Windows Containers category. That is a completely different story. It just doesn’t support desktop apps at all.

There is no Linux container on Windows. Linux containers run on Linux, Windows containers run on Windows. Docker Desktop can run a Linux virtual machine and containers inside that VM, but that is a remote machine which means you would need to send the GUI back to the client so not ideal.

Thoughts in this:
Using XLaunch with Docker allows you to run GUI applications from a Docker container on a Windows host.

  1. Install VcXsrv:
  • Download and install VcXsrv from its SourceForge repository.
  • During installation, choose the default options.
  1. Configure XLaunch:
  • Run XLaunch from the Start menu.
  • Select “Multiple windows” and click “Next”.
  • Choose “Start no client” and click “Next”.
  • Ensure “Disable access control” is checked and click “Finish”.
  1. Set up Docker:
  • Create a Dockerfile for your GUI application. Here’s an example for running Firefox:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
CMD /usr/bin/firefox
  • Build the Docker image:
docker build -t firefox .
  1. Run the Docker container:
  • Set the DISPLAY environment variable to your host’s IP address:
set-variable -name DISPLAY -value YOUR-IP:0.0
  • Run the Docker container with the DISPLAY variable:
docker run -ti --rm -e DISPLAY=$DISPLAY firefox
1 Like

Yes, that is what I referred to in my first reply but pet-clinic confused me for some reason and I didn’t notice that you answered my question that you use Linux containers (I moved the topic to the right category). It is still good that you described how it is done on Windows as that is the OS I use the less frequently. and couldn’t have done it quickly.

So you have a way to forward the GUI to your Windows host, but what is the problem with accessing the jfx modules in a container?

If you can share error messages or any specific there is a better chance you get help.