Skip to content

Instantly share code, notes, and snippets.

@shaybix
Last active January 21, 2017 19:13
Show Gist options
  • Save shaybix/bb6ea1cbf59534a606dc0e901d85a97d to your computer and use it in GitHub Desktop.
Save shaybix/bb6ea1cbf59534a606dc0e901d85a97d to your computer and use it in GitHub Desktop.

1 - Run on the first machine

docker swarm init

2 - Run on other machines to be included to the cluser (swarm)

docker swarm join <IP of manager>:2377

3 - To run new services (containers)

docker service create --replicas <number> --name <name to be given service> --network <network name> -p <container-port:host-port> <name of image>

4 - To scale up or down a service

docker service update --replicas <number> <service name>

5 - To constrain services to certain machines with labels

docker service create --replicas <number> --name <service name> --network <network name> -p <container-port:host-port> --constraint <key==value> <image name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment