Deploying via Docker

Last updated on 6th May 2024

Building via Docker

Before you begin make sure your model is added inside org.models package, and registered inside the main class. You should also confirm being able to run locally before deploying.

Building using Maven

The first step is to make a few changes to your pom.xml (if not pulling from the quickstart repo). Make sure you add the jodatime and junit versions to your properties section.



You will then want to add the jodatime and junit dependencies to the section starting with ''

previous dependency used junit, this has been replace with the junit-jupiter-api.



Finally you will add the plugins for assembling and dockerize-ing the project.


        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
    <entryPoint>["java", "-jar", "/${}-allinone.jar"]</entryPoint>
    <!-- copy the service's jar file from target into the root directory of the image -->

License file

The pom.xml above expect the license file to be named licenseKey and to be present in the root of the project directory, alongside You need to update these paths if you use a different location to ensure the license file is added to the docker image. If not, an error will be thrown at runtime as the license will not be present.

Properties File

If you are using the default '' file you can proceed. If however, you are using multiple '.properties' files (such as a different setting for working with Spark) you will need to change a few things:
  1. Change the name of the targeted property file (default to ``)with the name and location of your own.
  2. Edit the entryPoint field to add the '-DsimudyneConfigFile' and '-DsimudyneConfigDir' as you would normally do for running.

Building the image

Build the image by running 'mvn clean package docker:build -s settings.xml' inside the project's folder. This will create a docker image using the dockerfile generated by mvn in the way defined inside 'pom.xml'.

Pushing to Docker Hub

You will now push the docker image you have created to the Docker hub. You will want to replace the following things.

  • [build] - This will be the output you get from running the docker command above. It will change based on method and version but should look similar to 'simudyne-sbt-java-2.0.0-beta.2' or 'simudyne-maven-docker' You can confirm the name by running 'docker images' to see the latest created image.
  • [account] - Your account on the docker hub
  • [repo-name] - The name of the repository you've created on the hub.
  • [tag] - Tag is a useful method such that you can pull different files from your repo.

An example of this would be simudyne/simu-repo:demos

sudo docker tag [build] [account]/[repo-name]:[tag]
sudo docker push [account]/[repo-name]

You should be able to navigate to the Docker hub and confirm your image has been updated.

Logging into Docker

You must first run 'docker login' before you can push or pull to a repo. This will automatically ask for your account and password.

Deployment on Server

You must first log into the VM or server which you are deploying on. Please make sure the appropriate firewall and ports are made available based on either your public or intranet settings.

Pull the image using the details you specified above.

sudo docker pull [account]/[repo-name]:[tag]

You will likely already be running a container if not please skip to the next step. However, if you are you need to stop the existing container.

sudo docker ps #to identify the container ID
sudo docker stop <containerID>

You will then look for the exact image name, and then run it with the following configuration options.

  • - get the exact name from the 'docker images' command.
  • - replace with to have it available on all IPs of the host
  • - replace with 80 to have it available on default HTTP port

An example of this would be 'docker run -p 80:80 f3c0fa608b22 80'

sudo docker images # to have a look at the available images and get ImageID
sudo docker run -p <port>:<port> <ImageID> <ip> <port>
If you get a connection reset error, or if your log displays only accessible locally you need to update your property file. Set nexus-server.hostname = If you use the default property file (, simply remove the # that comment the line.

Once completed you should be able to go to the IP or DNS address of the server you've deployed on (mind the port) and see the console as you would locally.