Docker Dropwizard image

Made an example Docker image for running a Dropwizard Application in a container.


terminal gif


To run locally:

gradle run
# ./go

To build docker image:

gradle dockerBuildImage
# ./ (requires oneJar task to build dropwizard application)

To run docker image:

gradle dockerRunImage
./ (requires built image)

When image is running use boot2docker ip to get the docker IP and docker ps to see the port assigned to the container port 8080, then curl http://<dockerip&gt;:<port>/hello to call the dropwizard application running in the container.

If using LINUX you can use localhost and have to sudo docker commands.


This is a bare bones example for building an image for running a single Dropwizard application. It uses the standard docker java:jre-8 image as base, copies necessary files into image folder/opt/dropwizard and runs command to start dropwizard application.


FROM java:8-jre
COPY config.yml /opt/dropwizard/
COPY build/libs/docker-dropwizard-application-standalone.jar /opt/dropwizard/
WORKDIR /opt/dropwizard
CMD ["java", "-jar", "-Done-jar.silent=true", "docker-dropwizard-application-standalone.jar", "server", "config.yml"]


This is a simple way of defining a disposal container for a dropwizard application, taking effort away from operations and making the development team responsible for how their application will be hosted and run. Your application will be completely isolated from other parts of your solution running on the same host machine, including other instances of the same application for scaling and redundancy.

Instead of thinking of instances of your application, you have instances of your container image, hosted on one or more docker hosts depending on your architecture. Used correctly, you can create container instances as needed, kill when done, using versioning of images to release new versions of the service.

Things to consider:

  • How to extract information from running container instance application (logging, performance monitoring etc.)
  • Port management, how to create new containers with dynamic port allocation (to avoid collisions) while still balancing load between them
  • General release management using Docker
  • Configuration can be controlled by mounting configuration files to the container from the host rather than copying or adding them into the image (configuration per container instance rather than per image)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s