Meanwhile, follow along this presentation I made during DockerCon 2018 https://dockercon2018.hubs.vidyard.com/watch/k3Cv676wmxAwYDxbvcgcgC
This repo gives a few examples of patterns for how you might build Docker Swarm clusters with all the bells and whistles.
A Docker Swarm cluster needs more then just your app running, it often needs at least these additional services:
- Layer 7 Reverse Proxy (to host multiple HTTP sites on one port)
- Swarm-aware storage for data persistance
- Centralized logging of your app containers
- Centralized monitoring of nodes and containers
- Cluster management GUI
- Continuous deployment of updated images
This demo is meant for you to git clone
and run locally to help you learn the tools and methods for building a complete Docker Swarm cluster.
- Pull out everything that needs envvars
- Use Docker Swarm Secrets for privates
- Fix Docker EE Ansible permissions on ELB's and Security groups for port 8080 (app ELB)
- Better README step-by-step
- Walkthough videos
This repo holds two deployment examples for Docker Swarm
- Docker Swarm CE (Community Edition) open source stack
- Docker Swarm EE (Enterprise Edition) stack
The EE stack requires at least a trial license to deploy.
You can do all this locally on a single node or optionally using Docker Machine to multi-node clusters.
The scripts and compose/stack files use variables to make this demo easier to get started. Set these at your shell before running commands
# for Digital Ocean docker-machine driver
SSH_FINGERPRINT #fingerprint used to match your SSH key to Digital Ocean's
DO_SIZE #instance size for Digital Ocean to use for docker-machine
DO_TOKEN #Digital Ocean API token for creating/deleting droplets
# for Digital Ocean block storage
REXRAY_DO_TOKEN #Digital Ocean API token so RexRay can create storage volumes, can be same as DO_TOKEN
Just have Docker installed, either via Docker for Windows/Mac or on Linux. See my YouTube videos on the proper way to setup your OS for Docker using downloads from store.docker.com.
Then just create a single-node Swarm in that engine:
docker swarm init
./create-servers.sh
gives example docker-machine commands for creating 3 nodes in various VM environments including locally with VirtualBox, Hyper-V, and in the cloud using Digital Ocean.
./enable-monitoring.sh
simply overwrite /etc/docker/daemon.json
(we assume it doesn't exist) with two options to enabling the metrics endpoint, which will help Prometheus with more metrics.
{
"metrics-addr" : "0.0.0.0:9323",
"experimental" : true
}
- Don't throw out the good in search of the perfect
- DM works fine solo admins with 3-20 cloud servers
- Be sure to backup certs from .docker/machine/machines
- If you're a team of 2-3 and still want to try sticking with DM, maybe try:
- You can optionally deploy
stack-visualizer.yml
early on to see how your stacks and services fill out your swarm on port 4040.
docker stack deploy -c stack-visualizer.yml viz