JavaFx Maven Docker Image

Recently when setting up a Jenkins build environment to use a Docker Image with Maven that could build a JavaFX project.  Thanks to some searching and a bit of hunting I was able to create a Docker image to perform just what I needed: OpenJDK, OpenJFX(JavaFX), and Maven. I wanted the DockerFile to be a part of my project so that if changes were necessary down the road I could make them in Git and my build environment would pick them up.

  1. I began by creating a docker directory in my maven project.  This gives me the ability to modify the Dockerfile as needed for my project.
  2. Next, you need to download the official package of files for Maven.  I choose to use the maven:jdk-8 as my base image. When you download this Dockerfile, do not make the mistake I did and miss the and settings-docker.xml files you will need these.  Place all three files in your docker directory.
  3. Now you need to modify the Dockerfile to include in OpenJFX on top OpenJDK in the environment. Add the lines I have highlighted below:
  4. Next, since you put these files in a subdirectory you need to make another slight change:
  5. For completeness I will include the code for the other two files here as well:


With this, you now have a Dockerfile that supports JavaFX compilations in Maven.

One thought on “JavaFx Maven Docker Image

Leave a Reply

Your email address will not be published. Required fields are marked *