Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker Machine Swarm

Docker Machine Swarm

http://www.meetup.com/Docker-Tel-Aviv/events/221950270/

Overview of Docker Machine and Docker Swarm
by Evgeny Zislis

Show the latest updates and news coming from Docker about Docker Swarm and Docker Machine.

Video (in hebrew) https://youtu.be/eCFReLak7Ps

ProdOps

May 03, 2015
Tweet

More Decks by ProdOps

Other Decks in Technology

Transcript

  1. static website user data web frontend queue analytics development environments

    qa servers customer data center public cloud production cluster
  2. create machines docker-machine create \ --driver virtualbox \ machine_name Amazon

    EC2, Azure, DigitalOcean, Google Cloud Engine, OpenStack, RackSpace, Softlayer, VirtualBox, VMware Fusion, VMware vCloud Air, VMware vSphere docker machine
  3. create machines $ docker-machine create -d virtualbox dev INFO[0000] Creating

    SSH key... INFO[0000] Image cache does not exist, creating it at /Users/evgeny/.docker/machine/cache... INFO[0000] No default boot2docker iso found locally, downloading the latest release... INFO[0000] Downloading latest boot2docker release to ~/.docker/machine/cache/boot2docker.iso INFO[0062] Creating VirtualBox VM... INFO[0068] Starting VirtualBox VM... INFO[0069] Waiting for VM to start… INFO[0123] "dev" has been created and is now the active machine. INFO[0123] To point your Docker client at it, run this in your shell: eval "$(docker-machine env dev)" docker machine
  4. configure the docker client docker-machine env machine_name $ eval "$(docker-machine

    env foobar)" $ env | grep DOCKER docker-machine config machine_name $ docker `docker-machine config machine_name` ps docker machine
  5. docker-machine ssh machine_name $ docker-machine ssh foobar some_command docker-machine ip

    machine_name docker-machine url machine_name connect to machines docker machine
  6. docker-machine inspect machine_name docker-machine stop machine_name docker-machine start machine_name docker-machine

    kill machine_name docker-machine rm machine_name manage machines docker machine
  7. create a swarm docker-machine create -d virtualbox \ --swarm \

    --swarm-discovery token://26504993705d190ddddda6db575934f8 \ --swarm-master \ beequeen docker-machine create -d virtualbox \ --swarm \ --swarm-discovery token://26504993705d190ddddda6db575934f8 \ beeworker0 ... docker swarm
  8. $ eval "$(docker-machine env --swarm beequeen)" $ env|grep DOCKER DOCKER_HOST=tcp://192.168.99.101:3376

    DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=~/.docker/machine/machines/beequeen connect to a swarm manager docker swarm
  9. $ docker info inspect a swarm docker swarm Containers: 5

    Strategy: spread Filters: affinity, health, constraint, port, dependency Nodes: 4 beequeen: 192.168.99.100:2376 └ Containers: 2 └ Reserved CPUs: 0 / 4 └ Reserved Memory: 0 B / 1.025 GiB beeworker0: 192.168.99.101:2376 └ Containers: 1 └ Reserved CPUs: 0 / 4 └ Reserved Memory: 0 B / 1.025 GiB beeworker1: 192.168.99.102:2376 └ Containers: 1 └ Reserved CPUs: 0 / 4 └ Reserved Memory: 0 B / 1.025 GiB beeworker2: 192.168.99.103:2376 └ Containers: 1 └ Reserved CPUs: 0 / 4 └ Reserved Memory: 0 B / 1.025 GiB
  10. $ docker ps swarm containers docker swarm CONTAINER ID …

    PORTS NAMES a6d11e0760f7 … 2375/tcp beeworker2/swarm-agent e4a05f4f1291 … 2375/tcp beeworker1/swarm-agent eb2f5fbb295c … 2375/tcp beeworker0/swarm-agent b6f144eea15c … 2375/tcp beequeen/swarm-agent 5c6d7bf83ff4 … 192.168.99.100:3376->3376/tcp, 2375/tcp beequeen/swarm-agent-master
  11. $ docker-swarm create# use hub.docker.com tokens 09d27ee662e9b31a371e1886377faeb8 $ docker-machine …

    \ --swarm-discovery token://09d27ee662e9b31a371e1886377faeb8 swarm discovery - hosted docker swarm
  12. Static Files, etcd, Consul, ZooKeeper, IP List file:///tmp/my_cluster # echo

    <node_ips1:2375> >> my_cluster etcd://<etcd_ip>/<path> consul://<consul_addr>/<path> zk://<zookeeper_addr1>,<zookeeper_addr2>/<path> nodes://<node_ip1:2375>,<node_ip2:2375> # create a manager for a swarm docker-swarm manage -H tcp://<swarm_ip:swarm_port> <discovery_string> swarm discovery docker swarm
  13. # put swarm-agent IP:port in a file $ echo "10.0.0.[11:100]:2375"

    >> /tmp/my_cluster $ echo "10.0.1.[15:20]:2375" >> /tmp/my_cluster $ echo "192.168.1.2:[2:20]375" >> /tmp/my_cluster # run a manager swarm manage -H tcp://<swarm_ip:swarm_port> file:///tmp/my_cluster swarm discovery - patterns docker swarm
  14. swarm constraint filter # docker daemon on a host docker

    -d --label storage=ssd \ --label region=us-east-1 # filter containers in a swarm docker run -d -P --name db \ -e "constraint:storage==ssd" \ mysql docker swarm
  15. swarm built-in constraints • storagedriver • executiondriver • kernelversion •

    operatingsystem docker run -e "constraint:storagedriver=aufs" docker run -e "constraint:operatingsystem=fedora" docker swarm
  16. swarm affinity filter docker run -d -p 80:80 --name front

    nginx docker run -d --name logger \ -e affinity:container==front \ logger docker run -d --name redis1 \ -e affinity:image==redis \ redis docker swarm
  17. $ docker run -d -p 80:80 nginx $ docker run

    -d -p 80:80 nginx # when no hosts available with free ports - 2014/10/29 00:33:20 Error response from daemon: no resources available to schedule container swarm port filter docker swarm
  18. -m="": Memory limit format: <number><optional unit>, where unit = b,

    k, m or g -memory-swap="": Total memory limit (memory+swap) -c, --cpu-shares=0: CPU shares (relative weight) docker cgroup constraints docker 1.6
  19. > swarm manage --strategy <strategy_type> • spread (default) • binpack

    • random swarm scheduler strategies docker swarm
  20. builder resource constraints > docker build -h Usage: docker build

    [OPTIONS] PATH | URL | - Build a new image from the source code at PATH -c, --cpu-shares=0 CPU shares (relative weight) --cpuset-cpus= CPUs in which to allow execution (0-3, 0,1) ... -m, --memory= Memory limit --memory-swap= Total memory (memory + swap), '-1' to disable swap ... docker 1.6
  21. Example: Change state interactively, then add ports after the fact.

    > docker commit \ --change 'EXPOSE 80' \ --change 'CMD ["nginx"]' \ container_name \ new_image_name modify images docker 1.6
  22. Example: docker import to squash an image into a single

    layer > docker export myimage | \ docker import - --change 'EXPOSE 80' new_name modify images docker 1.6
  23. Example: docker import to squash an image into a single

    layer > docker run --log-driver=syslog … > docker run --log-driver=none … > docker run --log-driver=json-file … logging driver docker 1.6
  24. > docker -d --default-ulimit nproc=1024:2048 > docker run -d --ulimit

    nproc=2048:4096 httpd container ulimits docker 1.6
  25. > cgcreate -a user -g memory,cpu:groupname > docker run -d

    \ --cgroup-parent /sys/fs/cgroup/memory/groupname \ httpd container cgroup parent docker 1.6
  26. We invite you to join Operations Israel Facebook group on

    on.fb.me/Ops-IL link to slides dvps.me/docker-machine-swarm link to video (hebrew) youtu.be/eCFReLak7Ps Thank you! www.devops.co.il