Docker With Spring Boot and MySQL: Docker Swarm Part 3

Docker Swarm mode

In my previous two articles, I wrote about docker basic and docker-compose where we deployed real applications to a Docker container with Docker CLI and docker-compose. In the first article, we used Dockerfile to set up our environment and deployed the application by running containers separately and then built a link between each of them.

In the second article, we ran multiple containers with the docker-compose tool. But for scaling and high-availability, we need to run our application on multiple host machines with cluster facilities. For orchestrating distributed systems at any scale to gain scalability and high availability, Docker has its own implementation called Swarm. Swarm uses the SwarmKit library for orchestration.  

How to Create a Docker Machine with A Bridged Network Adapter

Introduction

In many cases, we need a central Docker machine hosted in a machine available in our local network. But the problem is that when we create a Docker machine in the considered host, it cannot be accessible from the other machines in our local network. This is due to the fact that the recently-created Docker machine gets its IP address from the host-only adapter network which only is visible from the local host. In other words, we can only access the Docker machine from the host which contains the Docker machine. In this article, I will propose a way to make the Docker machine available for any host in the local network.

Create a Docker Machine

First, we need to create a Docker machine. From now on, we will call it "local-docker-host." The command will be like this: