What is Docker?

Preamble: If you are already knowing what docker is you can easily skip this part.

Docker is probably the most popular software container platform. By design it isolates its content from the outside.

Benefits of using it are the just mentioned isolation, automated creation and portability across different environments.

If you are comfortable with virtual machines — they are very comparable. The main conceptional difference is that VMs are virtualizing the hardware and containers are virtualizing the operating system. Containers are running in user-space and are sharing the same kernel. Because of this difference they are more lightweight in terms of disk space and are booting up much faster. But enough now about the abstract talk here…

Let’s get it started

So where are we?

I just initialized the repository with a .gitignore and an almost empty README.md like every good project should setup its repository.

Like I told you I have no previous experience with Docker myself besides basic knowledge about containers. So I started a quick google research about it. My first few results brought me to the conclusion that there is something called “Docker Compose”.

Compose is a tool for defining and running multi-container Docker applications. — https://docs.docker.com/compose

Which just sounds perfect for my use-case in bringing up a container for each service we will be developing. Together with Docker itself this should be good.

The ugly part

After installing Docker from https://www.docker.com/ I started with creating a Dockerfile inside a subfolder called ‘template-service’. This file will be the foundation for each container we will be creating. Thankfully our containers will be very similar since everything is based on Java.

At this point I stumbled across https://spring.io/guides/gs/spring-boot-docker/ which is a guide for generating Docker images from mvn or gradle. I was not convinced if that is what i wanted. Still it pointed me to the linked Dockerfile: Which ended up with small modifications inside my template-service folder. The final file can be seen here: Link to Dockerfile.

In the root folder of the project I created the docker-compose.yml.

By following https://docs.docker.com/compose/gettingstarted/ I came up with a pretty easy understandable docker-compose.yml which still fits my needs. Feel free to read the tutorial it is really nice and understandable!

The two resulting files can be seen in the screenshot below.