Run Quarkus inside docker | Dockerizing a Quarkus Application

Share on:

This article will guide you through building Docker image for Quarkus application and to run Quarkus application inside the docker container.

What you are building

You are building docker image for Quarkus. Docker is a lightweight Linux container for running applications in a containerized model. In this article we are focusing on building docker image first. After the successful image build we are going to run Quarkus inside Docker container.


Recently Docker has started its support for Windows operating system also. If you are using Windows 10 then you can use Docker’s installer.

Get your Quarkus Application

Before we start building docker container you need to get your Quarkus application from GitHub Repo. (If you are new to Quarkus then i would highly recommend to go through my first tutorial on Getting Started With Quarkus | Quarkus Tutorial)

The cloned GitHub repository contains a bootstrap “Hello World"program using quarkus.

Here is “Hello World"restend point for our Quarkus application

 7public class HelloJhooq {
 9    @GET
10    @Produces(MediaType.TEXT_PLAIN)
11    public String hello() {
12        return "hello world ! From Jhooq";
13    }

Docker.jvm or Docker file

The GitHub project contains a Docker.jvm file and the same file we are goign to use for building our docker container.

 2# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
 4# Before building the docker image run:
 6# mvn package
 8# Then, build the image with:
10# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/hello-world-jvm .
12# Then run the container using:
14# docker run -i --rm -p 8080:8080 quarkus/hello-world-jvm
19ARG JAVA_PACKAGE=java-1.8.0-openjdk-headless
22ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
24# Install java and the run-java script
25# Also set up permissions for user `1001`
26RUN microdnf install openssl curl ca-certificates ${JAVA_PACKAGE} \
27    && microdnf update \
28    && microdnf clean all \
29    && mkdir /deployments \
30    && chown 1001 /deployments \
31    && chmod "g+rwX" /deployments \
32    && chown 1001:root /deployments \
33    && curl${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION} -o /deployments/ \
34    && chown 1001 /deployments/ \
35    && chmod 540 /deployments/ \
36    && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/
38# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
39ENV JAVA_OPTIONS=" -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
41COPY build/lib/* /deployments/lib/
42COPY build/*-runner.jar /deployments/app.jar
44EXPOSE 8080
45USER 1001
47ENTRYPOINT  "/deployments/" ]

Build docker image

To build the docker image use the following command

1docker build -f src/main/docker/Dockerfile.jvm -t quarkus/hello-world-jvm .

Once the docker image is built successfully afterwords you should see a following successful message

1Successfully built dca1588f66c3
2Successfully tagged quarkus/hello-world-jvm:latest

docker run : Run your image

Use following docker run command to run your docker image

1docker run -i --rm -p 8080:8080 quarkus/hello-world-jvm

Once you run the above docker run command then you should see the following logs

1exec java -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRati
2o=40 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app.jar
32020-03-25 19:01:10,691 INFO  io.quarkus] (main) hello-world 1.0.0-SNAPSHOT (running on Quarkus 1.2.1.Final) started in 0.993s. Listening on:
42020-03-25 19:01:10,718 INFO  io.quarkus] (main) Profile prod activated.
52020-03-25 19:01:10,719 INFO  io.quarkus] (main) Installed features: cdi, resteasy]

Now your docker container is built and running successfully.

The keypoint over here is - In the docker file, we have exposed the application on port 8080. So docker container will deploy our application on port 8080

docker ps : Running status of Quarkus Application

To check the docker running status you can use - docker ps -a

1$ docker ps -a
2CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                    NAMES
3f140ab48831f        quarkus/hello-world-jvm   "/deployments/run-ja…"   9 minutes ago       Up 9 minutes>8080/tcp   lucid_matsumoto

It will return you the active running docker container, which is in our case - quarkus/hello-world-jvm

docker stop : Stop Quarkus application

You can stop the Quarkus application using - docker stop <conatiner_id>

1$ docker stop f140ab48831f

YouTube - Tutorial


Well if you reach so far then congratulations you have successfully containerized your Quarkus application using docker. Now you can run build and deploy this container to any cloud platform such as AWS, Redhat Openshift.

For similar content please follow us on YouTube