Skip to content

Instantly share code, notes, and snippets.

@lachie83
Last active February 20, 2018 23:53
Show Gist options
  • Save lachie83/467c346f7b31f63a7b05ac717f4e1d06 to your computer and use it in GitHub Desktop.
Save lachie83/467c346f7b31f63a7b05ac717f4e1d06 to your computer and use it in GitHub Desktop.
15 minutes with Docker Swarm Mode

3 x Cluster on AWS

  • manager1
  • worker1
  • worker2

Docker-machine commands

Use docker-machine to lay down 3 x hosts on AWS using docker-engine 1.12

docker-machine create --driver amazonec2  --amazonec2-private-address-only --engine-install-url https://test.docker.com/ levenson-docker-swarm-manager1 
docker-machine create --driver amazonec2  --amazonec2-private-address-only --engine-install-url https://test.docker.com/ levenson-docker-swarm-worker1 
docker-machine create --driver amazonec2  --amazonec2-private-address-only --engine-install-url https://test.docker.com/ levenson-docker-swarm-worker2 

Bootstrap cluster

On manager1

docker swarm init --listen-addr <manager1:eth0-addr>:2377

On worker1/2

docker swarm join  <manager1:eth0-addr>:2377

Confirm Cluster State

docker node ls
ID                           NAME                            MEMBERSHIP  STATUS  AVAILABILITY  MANAGER STATUS
2d38pr0i29f3b0ow0h124pl3t    levenson-docker-swarm-worker2   Accepted    Ready   Active        
7q62jyv94ofnr66rsp1uqa730 *  levenson-docker-swarm-manager1  Accepted    Ready   Active        Leader
8zfyhauh35avz5t25gz0j1ugy    levenson-docker-swarm-worker1   Accepted    Ready   Active

Deploying services

docker service create --replicas 1 --name croc-hunter -p 8080:80 --update-delay 10s --update-parallelism 1 lachlanevenson/croc-hunter:v1
docker service tasks croc-hunter
docker service inspect croc-hunter

Scale services

docker service scale croc-hunter=3
docker service tasks croc-hunter

Rolling-update services

docker service update --image lachlanevenson/croc-hunter:v2 croc-hunter
docker service tasks croc-hunter

Drain a node

docker service tasks croc-hunter
docker node update --availability drain levenson-docker-swarm-worker1
docker node inspect --pretty levenson-docker-swarm-worker1
docker service tasks croc-hunter
docker node update --availability active levenson-docker-swarm-worker1
docker node inspect --pretty levenson-docker-swarm-worker1
@Laxman-SM
Copy link

unable to find the tasks command on latest release 1.12.0.

docker@infra:~$ docker service tasks

Usage: docker service COMMAND

Manage Docker services

Options:
--help Print usage

Commands:
create Create a new service
inspect Display detailed information on one or more services
ps List the tasks of a service
ls List services
rm Remove a service
scale Scale one or multiple services
update Update a service

Run 'docker service COMMAND --help' for more information on a command.

docker@infra:$ docker --versiondocker@infra:$ docker version
Client:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 23:54:00 2016
OS/Arch: linux/amd64

Server:
Version: 1.12.0
API version: 1.24
Go version: go1.6.3
Git commit: 8eab29e
Built: Thu Jul 28 23:54:00 2016
OS/Arch: linux/amd64
Docker version 1.12.0, build 8eab29e

@Laxman-SM
Copy link

with 1.12 task sub command deprecated.

@mrsimonemms
Copy link

mrsimonemms commented Nov 14, 2016

@Laxman-SM It seems the docker service tasks command has been replaced with docker service ps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment