# Docker and Javafx

**URL:** <https://forums.docker.com/t/docker-and-javafx/143498>\
**Category:** Docker Desktop\
**Tags:** windows\
**Created:** [September 1, 2024, 6:14pm UTC](https://forums.docker.com/t/docker-and-javafx/143498 "2024-09-01T18:14:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggblake](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ggblake/32/50949_2.png) [@ggblake](https://forums.docker.com/u/ggblake)\
**Post date:** [September 1, 2024, 6:14pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/1 "2024-09-01T18:14:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 1, 2024, 7:10pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/2 "2024-09-01T19:10:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ggblake](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ggblake/32/50949_2.png) [@ggblake](https://forums.docker.com/u/ggblake)\
**Post date:** [September 1, 2024, 7:52pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/3 "2024-09-01T19:52:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 1, 2024, 8:42pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/4 "2024-09-01T20:42:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ggblake](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ggblake/32/50949_2.png) [@ggblake](https://forums.docker.com/u/ggblake)\
**Post date:** [September 6, 2024, 1:37pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/5 "2024-09-06T13:37:10Z")

</div>

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:

```auto
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
CMD /usr/bin/firefox

```

- Build the Docker image:

```auto
docker build -t firefox .

```

1. **Run the Docker container** :

- Set the `DISPLAY` environment variable to your host’s IP address:

```auto
set-variable -name DISPLAY -value YOUR-IP:0.0

```

- Run the Docker container with the `DISPLAY` variable:

```auto
docker run -ti --rm -e DISPLAY=$DISPLAY firefox

```

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 6, 2024, 7:22pm UTC](https://forums.docker.com/t/docker-and-javafx/143498/6 "2024-09-06T19:22:12Z")

</div>

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.
