How to deploy Spring Boot application using Docker

Welcome to the ToraCode blog. I’m Sayem and I’ll discuss how to deploy Spring Boot app on your local machine using docker.

Wait, what is Docker? I didn’t know about that!! why didn’t you tell us about docker in the first place?

Well, if you don’t know about docker yet, it’s fine. Let me explain a little bit for you.

Docker is a virtualisation management software for managing containers and images.


Now what is containers and images? okay let me clear some concepts here

  • A container is a run time environment for images
  • An image is a software that you run within the containers.
  • Image is built using layers. Suppose you have an existing image, you added your app and built a new image and other people can build an image on top of your image.

Screen Shot 2016-08-22 at 8.32.52 PM

  • Suppose you’ve a spring boot app and you built it using Java 8. So your base image is Java 8 and after adding your app you’ll create a new image. Just like layers, you see? Java 8 api is base layer, and you added your code/layer and made a new image. Other people can add their code/layer and create their own image. It works like that.

So what docker does actually?

  • Build that image
  • Deploy those images into containers
  • And manage those containers like starting and stopping those containers.

Why should we use Docker in the first place?

  • It’s easy to build docker images and put it into containers
  • It’s lightweight
  • It’s cloud agnostic. That means you don’t have to worry about particular version of linux is available or not, several cloud platforms support docker and you can just move your docker container from one cloud platform to another.
  • And it’s scalable. You can startup multiple containers with you image in a matter of seconds.

So let’s install docker. it’s available for Linux, Mac or Windows.

Download Docker for your platform and install it.

You can check if it’s properly installed by running a command

docker ps

It shows the existing containers running with docker. Otherwise try adding docker to your environment variable.

Okay great!

Now that you are set up for using docker. Follow these next steps to deploy a sample spring boot app using docker.

2 thoughts on “How to deploy Spring Boot application using Docker

Leave a Reply

Your email address will not be published. Required fields are marked *