In this post we will deploy a web application with a Load Balancer in a docker Service using swarm.
You may want to read the previous articles:
Describe the application in a docker-compose.yml
version: "3"
services:
web:
image: legabz/hellokube:swagger
deploy:
replicas: 5
resources:
limits:
cpus: "0.1"
memory: 1G
restart_policy:
condition: on-failure
ports:
- "4000:8080"
networks:
- webnet
networks:
webnet:
Init host as a swarm manager node
docker swarm init
Deploy application
docker stack deploy -c docker-compose.yml myApp
List services
docker service ls
docker stack services myApp
List tasks
docker service ps myApp_web
docker container ls -q
docker stack ps myApp
Stop application
docker stack rm myApp
Take down swarm
docker swarm leave --force