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.

  • Ghostprogrammer
  • I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

One Comment

  • This does not really work for me.
    I have a docker jenkins image where I want to add javaxfx support.

    But adding the code as mentioned by “OpenJFX on top OpenJDK” results into the following when building the docker image. The very base image is
    FROM jenkins/jenkins:lts
    which is
    FROM openjdk:8-jdk

    here is what happens:

    $> sudo docker build -t greyshine/jenkins_jfx .
    Sending build context to Docker daemon 695.8kB
    Step 1/14 : FROM jenkins/jenkins:lts
    —> e6b6a36fca5a
    Step 2/14 : RUN apt-get update && apt-get install –no-install-recommends -y openjfx unzip && rm -f /var/lib/apt/lists/*_dists_*
    —> Running in 9f4ed98e2b91
    Reading package lists…
    E: List directory /var/lib/apt/lists/partial is missing. – Acquire (13: Permission denied)
    The command ‘/bin/sh -c apt-get update && apt-get install –no-install-recommends -y openjfx unzip && rm -f /var/lib/apt/lists/*_dists_*’ returned a non-zero code: 100

One Pingback

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: