Go back to Read chapters

Running Hashtag Messaging application inside a Docker container

Learn how to use a Docker container with downloadable tutorial Hashtag Messaging container application

How Docker works with Spring Boot?

In this chapter we introduce a new way of running the Java Spring Boot microservice: Inside a Docker container. You will get to download the source code, compile the service and launch it inside an own virtualized server that runs inside your host machine. Docker is currently our choise of technology for launching the service. Docker is an architecture that can be utilized for running a new virtualized computer instances. This means that it has it's own memory and disk where the service will be installed in. 

Requirements for running an application inside a Docker container

These instructions are tested only on a Windows host machine, they may apply also to Mac and Unix based systems. The commands running the container should apply to all environments.

You have to have the following setup installed on your host machine. 


Oralce VirtualBox On Window machines. This is required to start a virtual machine.


You will also need the source code project from the end of the article to compile, run and install as a microservice inside the container.

Hashtag Messaging application setup for Docker

Code Build and Run a new Microservice Spring boot application

The Docker needs a recipe file for the setup, h...


The Dockerfile has the following setup:

FROM frolvlad/alpine-oraclejdk8:slim


ADD messaging-0.0.2-SNAPSHOT.jar messaging.jar

RUN sh -c 'touch /messaging.jar'

ENTRYPOINT ["java","-Djava.security.egd=file:/d...

With just this setup you are able to launch the...

Maven POM.xml configuration for running a Docker package

You will also need a new maven plugin to build ...

























How to start Docker and run an application inside the container

Now that you have installed the Docker or the D...

Run a custom application inside Docker container

You have to launch the Docker instance inside t...

Change the directory to the folder where you ex...LOGIN TO READ FULL ARTICLE

cd /c/[your workspace directory]/messaging

mvn package docker:build

docker run -p 8080:8080 -t springio/messaging&n...LOGIN TO READ FULL ARTICLE

Test the new application with the Docker setup

Press Control + C to return back to the shell. ...

docker-machine ls

The command prints out the list of your Docker ...


The final URL depends on the machine that you'r...


This test fetches all the fresh message from th...


So go to the previous chapter and do the same P...

To stop the Docker container use the commands&n...

docker ps

docker stop [CONTAINER ID]


Now you have the Hashtag messaging API up and r...


- Changed messaging API version to v0.1, ...?

Old version v0.0.1 New version v0.0.2.1D

Dockerfile JAR version


 API version /v0.0.1/messages  /v0.1/messages

- Fixed error in setting default maximum offset...

Added Validation with twitter-text...

What new ideas or thoughts this chapter gave you?