Skip to content

bijeshos/spring-boot-with-docker

Repository files navigation

Spring Boot with Docker (Demo)

This is a simple Spring Boot application used for demonstarting intergration with Docker. This also includes a few configurations to show deployment on Docker Swarm.

Overview

Following are a few aspects being demonstrated:

  • Building Docker image using Dockerfile
  • Building Docker image using Maven
  • Basic deployment using Docker and invocation of health-check Rest API endpoint
  • Deployment using Docker Compose with 3 replicas
  • Deployment using Docker Compose with 3 replicas and visualizer

Prerequisites

  • JDK 8
  • Docker

Dev Environment

This application was tested on the following:

  • OS : Ubuntu 18.04 LTS
  • Docker: 18.09.3 (community)

Instructions

Get the project to local machine

Build the project

  • Perform Maven Build/Package
    • $ mvn package -f pom.xml

Docker (Basic)

Cleanup Docker

  • Check locally available docker images

    • $ docker images
  • Check all containers

    • $ docker ps -a
  • Remove any unwanted containers (by specifyig respective container id)

    • $ docker rm <container-id>
  • Remove any unwanted docker images (by specifying respective image id)

    • $ docker rmi <image-id>

Deploy on Docker

Cleanup Docker

  • Remove container

    • $ docker rm <container-id>
  • Remove docker image

    • $ docker rmi <image-id>

Docker Swarm (Basic)

Deploy on Docker Swarm Cluster

Docker Swarm (with Visualizer)

  • Deploy using Docker compose file

    • $ docker stack deploy -c docker-compose-02-with-visualizer spring-boot-with-docker-demo-stk
  • Check the visualize at:

Cleanup Docker Swarm Cluster

  • Remove docker stack

    • $ docker stack rm spring-boot-with-docker-demo-stk
  • Shutdown Docker Swarm Cluster

    • $ docker swarm leave --force

Assumptions

  • Docker commands can be executed directly as current user
    • If this is not correctly setup, prefix sudo with above mentioned docker commands (On Debian machines)

Reference

Future scope

  • Integration with Kubernetes

About

A simple spring boot application integrated with docker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published