Docker Learning Notes (vii)-How to create a docker swarm

Source: Internet
Author: User
Tags join ssh docker swarm
Create Docker Swarm

Here to summarize the official website of the document, but this section of the official website is not well written, the official website does not introduce how to create a node machine, need to find the previous documents to facilitate learning, the official website is best in the document to give relevant links, but no, this blog to add. Prerequisite 3 hosts capable of networking (Manager1, Worker1, Worker2) can be virtual machine, data center, a cloud service provider, etc. The Docker version of 1.12 or later. Open Ports Step STEP1 between the IP address hosts of the manager Machine . Establishing MANAGER1 Nodes

(1) Create this machine first

$ sudo docker-machine create--driver VirtualBox manager1

You should get output similar to the following:

mingchen@mingchen-hp:~$ sudo docker-machine create--driver virtualbox manager1 [sudo] password for mingchen:running pre
-create checks ... (Manager1) You are using version 4.3.36_ubuntur105129 of VirtualBox.
If you encounter issues, you might want to upgrade to version 5 at https://www.virtualbox.org Creating ... (Manager1) Copying/home/mingchen/.docker/machine/cache/boot2docker.iso to/home/mingchen/.docker/machine/machines/manager1/
Boot2docker.iso ... (Manager1)
Creating VirtualBox VM ... (Manager1)
Creating SSH Key ... (Manager1)
Starting the VM ... (Manager1)
Check network to re-create if needed ... (Manager1)
Waiting for an IP ...
Waiting for machine to is running, this could take a few minutes ...
Detecting operating system of created instance ...
Waiting for SSH to be available ...
Detecting the Provisioner ...
Provisioning with Boot2docker ...
Copying certs to the Local machine directory ...
Copying certs to the remote ...
Setting Docker configuration on the remote daemon ...Checking connection to Docker ...
Docker is up and running! Your Docker Client to the Docker Engine running on this virtual machine, Run:docker-machine env man
                  Ager1 mingchen@mingchen-hp:~$ sudo docker-machine ssh manager1 # #.  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~                 ~ ~ ~/===-~ ~ ~ \______ o __/\ __/\____\_______/_ _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) |   (__|
< __/| |_.__/\___/\___/\__|_____\__,_|\___/\___|_|\_\___|_| Boot2docker version 1.13.0, build head:5b8d9cb-wed Jan 18:50:40 UTC Docker version 1.13.0, build 49bf474 Docke r@manager1:~$

(2) SSH log in the machine
This step is needed next time in a new window, since the first step has been created and has entered the machine,docker@manager1:~$
If in the new terminal window, then:

$ sudo docker-machine ssh manager1  

If you have already logged in, you do not have to do the above.
(3) Add Manager1 to the swarm as the primary node
Basis

Docker swarm Init--advertise-addr <MANAGER-IP>

Convert <MANAGER-IP> to Manager1 host IP

docker@manager1:~$ Docker swarm init--advertise-addr 192.168.99.101

Get the following output

Swarm initialized:current Node (qf12wwq4i3gjv4gnhiuetqiy5) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-1-4HGGSL45LCDTN8WD8M5 Y5QB4YEK2C1ZTJ6TIBKRSXE8LB8NYT2-07L8C6KE7BA6N4G235VGWDGI3 \
    192.168.99.101:2377 to

add a manager to this Swarm, run ' Docker swarm Join-token Manager ' and follow the instructions.

docker@manager1:~$

The above output contains how to add worker and manager. However, the added operation is performed on a different terminal machine. STEP2. Creating/adding Worker1 nodes

(1) Create a worker1 node machine in another new terminal window using a method similar to STEP1.

mingchen@mingchen-hp:~$ sudo docker-machine creat--driver VirtualBox worker1

(2) SSH login

mingchen@mingchen-hp:~$ sudo docker-machine ssh worker1
                        # #         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~< c9/>\______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| | __   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/|
| _.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2docker version 1.13.0, build head:5b8d9cb-wed Jan 18:50:40 UTC
Docker version 1.13.0, build 49bf474< c31/>docker@worker1:~$

(3) Add the Worker1 node into the swarm with Manager1 as manager

docker@worker1:~$  docker swarm join \
>     --token Swmtkn-1-4hggsl45lcdtn8wd8m5y5qb4yek2c1ztj6tibkrsxe8lb8nyt2-07l8c6
ke7ba6n4g235vgwdgi3 \
>     192.168.99.101:2377 This
node joined a swarm as a worker.
STEP3. Creating/adding WORKER2 nodes

Basically the same as STEP2. STEP4. Viewing node information in Manager1 terminal

Input Docker node ls

docker@manager1:~$ Docker node ls

The manager's column leader is Manager1
Use a similar approach to add more nodes.

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.