Docker Swarm cluster in one command
Yup, creating a 3 node cluster is simply:
miniswarm start 3When you're done:
miniswarm delete
Miniswarm is a tool that intends to make creating and managing a local Docker Swarm cluster as easy as possible. Miniswarm was inspired by Minikube which does a similar thing for kubernetes clusters. See FAQ below for info on managing a remote Swarm cluster.
The tool takes less than 10 minutes to learn, see the tutorial section below, or watch this tutorial video: * Miniswarm: Local Docker Swarm Cluster and Docker health check Tutorial
In this tutorial we'll install miniswarm, create a Swarm cluster, deploy some apps and learn all the features of miniswarm in the process.
# As root curl -sSL https://raw.githubusercontent.com/aelsabbahy/miniswarm/master/miniswarm -o /usr/local/bin/miniswarm chmod +rx /usr/local/bin/miniswarm
# 1 manager 2 workers miniswarm start 31 manager cluster - if you want a smaller cluster
miniswarm start
2 managers 3 workers - nice laptop or desktop :)
miniswarm start 2 3
A couple of minutes later, you should get this message
INFO: Stack starup complete. To connect to your stack, run the following command: INFO: eval $(docker-machine env ms-manager0)
This will open a browser with a nice visualization of your Docker Swarm using docker-swarm-visualizer
miniswarm vis
This service will be unhealthy due to failing Goss healthchecks and missing dependencies. See next few steps for how we can debug and remedy this. ```
eval $(docker-machine env ms-manager0)
docker network create -d overlay healthyvote_net
docker network ls
docker service create -p 8080:80 --replicas 2 --network healthyvote_net --name vote aelsabbahy/healthyvote ```
# Wait for the service to finish preparing, but it won't ever be ready due to failing health docker service ls docker service ps voteLets look at the healthchecks using miniswarm
-a shows all containers, including exited/failed containers
miniswarm health vote -a
We should see something like this:
[ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] ====== [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Start: 2016-08-07 22:39:03.748704565 +0000 UTC [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] ====== [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] .F [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Failures/Skipped: [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Title: Redis backend is reachable [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Meta: [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] remedy.1: Deploy redis service if you haven't already [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] remedy.2: ctrl-alt-delete [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] remedy.3: take a nap aka human ctrl-alt-delete [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Addr: tcp://redis:6379: reachable: [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Expected [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] : false [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] to equal [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] : true [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Total Duration: 0.500s [ms-worker0 vote.2.630mookf9pnc8dip5hl7yng3q] Count: 2, Failed: 1, Skipped: 0
Lets remedy the healthcheck issue
docker service create --replicas 1 --network healthyvote_net --name redis redisWait for it to show up in
miniswarm vis
or by using CLIdocker service ls docker service ps redis
Now that redis is deployed, the vote service should now be running
docker service ls
And the health..
miniswarm health vote
# Open app in browser miniswarm service voteprint url, but don't open (--url has to be at the end for now)
miniswarm service vote --url
miniswarm logs voteTail the log file (-f has to be at the end for now)
miniswarm logs vote -f
# Take a look at `miniswarm vis` GUI to see the services move around as we scale down miniswarm scale 2
miniswarm delete
The tool was written with local Swarm cluster in mind. That said, it can probably be used to manage a remote Swarm clusters, but that hasn't been tested. Take a look at MACHINE_DRIVER variable at the top of the script.
In theory, if you set the MACHINE_DRIVER variable to the driver you want + any required variables from the driver itself, see supported drivers it should just work. Feel free to submit a pull-request to improve this or add more support.
MS_NOCOLOR=1 miniswarm ..or
export MS_NOCOLOR=1 miniswarm ...
It should, but I don't own a Mac, so I depend on others to verify it. So.. if something is broke on mac, please submit a pull request.
Mostly shameless self-promotion, and while we're on the topic, check out: * Goss - Project page * blog post - Using Goss with Docker healthchecks and Kubernetes
Two reasons:
Honestly, I don't know.. I see them too. Either I'm doing something dumb, or Docker Swarm mode has intermittent DNS issues. Hopefully with more users we can get to the bottom of this.
Because Dockerhub doesn't support HEALTHCHECK in Dockerfile yet. The code for this image can be found in the healthyvote/ folder.
Because it's a quick hack I did over the weekend.. or I suck.. maybe both?
Open an issue, create a pull request.. contribute! :)
See the last two questions.