Skip to content

Instantly share code, notes, and snippets.

@jinnabaalu
Last active December 12, 2017 14:51
Show Gist options
  • Save jinnabaalu/6af16beec29cd8900d4f0dd942241815 to your computer and use it in GitHub Desktop.
Save jinnabaalu/6af16beec29cd8900d4f0dd942241815 to your computer and use it in GitHub Desktop.

Docker Swarm

To join a worker

docker swarm join --token <worker_token> <manager_ip>:2377

To join a manager

docker swarm join --manager --token <manager_token> --listen-addr <master2>:2377 <master1>:2377

Primary / Secondary Managers

REQUEST always goes to primary manager always, if the request goes to secondary manager then it is proxied to the primary one.

Primary manager will deligate the request to the different workers

Key Concepts of Docker Swarm

  • Manager are need to be odd in number, so that you can solve the split brain problem of the network
  • All masters configured using Raft Consensus Group
  • All workers communicates through the Gossip Network

Create the Service

docker service create --replicas 3 --name job jboss/wildfly

Node Failure,

if the service goes down or container goes off, this this replicas check failes the

**desired(3 replicas) !== actual(one failed and 2 runningg) **

Then docker reconciles the replicas to 3.

Container failure

Same as the the node failure to fire up the new container

Scale

docker service scale web=6

Global Service

  • One instance of service running at each node(docker swarm machine) of the cluster with the mode as global.
docker service create --mode=global --replicas 3 --name job jboss/wildfly
  • when weexecute this command it fires up the command on each node of the cluster, downloads the image and creates the service at each node of the cluster

Docker Compose

  • Define and run multi container applications
  • Configuration defined in one or more files

FILE NAME

docker-compose.yml # default file name 

RUN

docker-compose up -d

FILE NAME

docker-compose-test.yml

RUN

docker-compose -f docker-compose-test.yml up -d

To run multiple compose files

docker-compose -f file1.yml -f file2.yml up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment