Intro Swarm Mode

This section will give you the necessary to go full to production with Docker swarm mode.

About me 1

Swarm vs K8

Docker swarm es mejor que kubernetes ....
pero ustedes no estan listos para esta conversacion

About me ![2](img/swarmvsk8.png) - Just Kidding
Features
  • Cluster management integrated with Docker Engine
  • Declarative service model
  • Scaling
  • Desired state reconciliation (The swarm manager node constantly monitors the desired state )
  • Multi-host networking
  • Service discovery
  • Load balancing
  • Secure by default (intra node)
  • Rolling updates
  • Hyper EASY

Setup

#!/bin/bash
# check swarm is enabled
docker info |grep -i swarm


docker swarm init || echo "Already in Swarm Mode"


docker node ls
#!/bin/bash
1. Go to http://play-with-docker.com sign in with your user:pass (create account if needed).
2. Click on the wrench and select either "3 Managers and 2 Workers" or "5 managers and no workers"
3. Unless instructed run all the commands on the first node.
4. Make sure to clone the repo in the swarm nodes (PWD)



git clone https://github.com/jmarcos-cano/compose-to-swarm.git
cd compose-to-swarm
#!/bin/bash
# Create 3 droplets with private networking enabled.
# WHY 3?

# install docker
export leader=165.227.74.229
export manager1=165.227.77.199
export manager2=165.227.65.241

ssh root@${leader} "docker version || curl -fsSL https://get.docker.com/ | sh " && \
ssh root@${manager1} "docker version || curl -fsSL https://get.docker.com/ | sh" && \
ssh root@${manager2} "docker version || curl -fsSL https://get.docker.com/ | sh"


ssh root@${leader} "sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64" -o /usr/bin/docker-compose &&  chmod +x /usr/bin/docker-compose" &&\
ssh root@${manager1} "sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64" -o /usr/bin/docker-compose &&  chmod +x /usr/bin/docker-compose" &&\
ssh root@${manager2} "sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64" -o /usr/bin/docker-compose &&  chmod +x /usr/bin/docker-compose"


# init swarm in 1 manager
#ssh root@${leader} "docker swarm init --advertise-addr eth1"

# get the manager join-token
#ssh root@${leader} "docker swarm join-token manager"


# Join the other managers


## PLUS!
docker -H ssh://root@${leader} node ls