Deploying Docker swarm clusters through Docker-machine and ETCD

Source: Internet
Author: User
Tags docker hub docker run docker swarm etcd docker machine

This article describes the use of Docker-machine to build a Docker swarm cluster; Docker swarm is the official Docker-built container cluster orchestration tool, and container orchestration allows you to use a cluster like a machine, The container you are running may run on any node in the container;

First, steal a Docker swarm architecture diagram:

Photo source https://yeasy.gitbooks.io/docker_practice/content/swarm/intro.html

When using Swarm to manage Docker clusters, there will be a Swarm manager and several Swarm Node,swarm manager running Swarm Daemon, the user only need to communicate with Swarm Manager, and then Swarm The manager then selects a swarm node to run the container based on the Discovery service information.

It is important to note that Swarm daemon is just a Task Scheduler (scheduler) and router (router), which itself does not run the container, it only accepts requests sent by the Docker client, dispatches the appropriate swarm node to run container. This means that even if swarm daemon has been hung up for some reason, the container that has been running will not have any effect;

Swarm manager needs to know which swarm node, which requires "service discovery" (with registration to find), swarm service discovery methods are many, here are two main experiments, that is, through the Docker hub token and ETCD;

(1) As mentioned in the previous article that Docker-machine,docker-machine is integrated with Docker swarm, the Docker hub token is made by applying a token to the Docker hub token via Swarm, Then add all of the node to this token;

First you need to go to the Docker hub to create a token through the swarm create command, and in the previous chapter we established a Docker machine called Hehe-dev;

Docker-machine ssh Hehe-dev landed in this machine

DAO pull Swarm downloads the swarm download image and uses Daocloud to accelerate

Docker run swarm create runs swarm create command to create a token, this token to keep in mind, the following with Swarm_token to replace the token;

Then exit Hehe-dev.

Docker-machine create-d VirtualBox--swarm--swarm-master--swarm-discovery token://swarm_token swarm-master build swarm m Anager and add it to token;

Docker-machine create-d VirtualBox--swarm--swarm-discovery token://swarm_token swarm-node-01

Docker-machine create-d VirtualBox--swarm--swarm-discovery token://swarm_token swarm-node-02 Then set up two swarm node, the name of their own random take, I chose here is swarm-node-01 and swarm-node-01 can not be underlined

Through the above steps, in fact, a swarm cluster has been established, through the Docker-machine LS can see the built up Docker machine, and then we want to see the cluster inside the situation:

Docker-machine ssh swarm-master Login to the Swarm-master node (in fact any machine can be logged into the cluster), and then run

sudo docker run--RM swarm list Token://swarm_token then you can see the node information in the cluster;

(2) ETCD is a distributed key-value system under the CoreOS project, which is mainly used for service discovery and configuration distribution, and is a service discovery component with ETCD as a swarm, which is actually similar, and the Etcd of a directory (Etcd://ip:port/dir format) is leaked to swarm node, and then each swarm node is connected to this directory, its own IP, port registered to the inside;

The first is to install ETCD, to Etcd's official website to download, github.com/coreos/etcd/releases, I am Mac OS X, the installation and startup commands are as follows:

Curl-l Https://github.com/coreos/etcd/releases/download/v2.3.0-alpha.1/etcd-v2.3.0-alpha.1-darwin-amd64.zip-o Etcd-v2.3.0-alpha.1-darwin-amd64.zip

Unzip Etcd-v2.3.0-alpha.1-darwin-amd64.zip

CD ETCD-V2.3.0-ALPHA.1-DARWIN-AMD64

./ETCD--data-dir=/tmp/default.etcd--listen-client-urls ' http://Native ip:4001 '--advertise-client-urls ' http//native IP : 4001 '

So the ETCD service is started.

Docker-machine create-d VirtualBox--swarm--swarm-master--swarm-discovery etcd://native Ip:4001/swarm Swarm-master-etcd;

Docker-machine create-d VirtualBox--swarm--swarm-discovery etcd://native Ip:4001/swarm swarm-node-etcd-01

Docker-machine create-d VirtualBox--swarm--swarm-discovery etcd://native Ip:4001/swarm swarm-node-etcd-02

The process of creating a service above is actually the same as token, but it is just a matter of saying that the URL of the ETCD replaces the token, and that the swarm cluster is made up of the same truth;


Deploying Docker swarm clusters through Docker-machine and ETCD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.