Docker-run containers using the network of overlay mode created in swarm mode

Source: Internet
Author: User
Tags docker run docker swarm

Objective

In Docker engine v1.12, using swarm can easily create a overlay mode network, but it can only be used by the service below Swarm, which is completely isolated relative to container. In v1.13, when running containers, you can join the overlay network that was previously customized in swarm mode!

1. Create swarm in one Docker host (172.100.1.17)

$ docker Swarm init–advertise-address 172.100.1.17

2. Wait for worker node joined

$ Docker Swarm Join-token worker

3. Join swarm from another Docker host (172.100.1.12)

$ docker swarm join--token SWMTKN-1-4KAJ1VANH45IHJFGUD7NFGAJ099GTVRGSSG4DXP4RIKD1KT1P1-6BWEP9VX83OPPOUZ0RFZ5SCF9 172.100.1.17:2377

4. Create Network on Manager node (172.100.1.17)

$ docker Network create-d overlay --attachable qrtoverlaynet

--attachable is the key, it shows that this network can be joined by container.

5. Create container by using overlay network "Qrtoverlaynet"

172.100.1.17

$ docker run-itd--name mybusybox--network qrtoverlaynet busybox

172.100.1.12

$ docker run-itd--name mybusybox12--network qrtoverlaynet busybox

6. Execute container and ping the containers in Differenct Docker hosts

Ping "BusyBox" from 17

Ping "BusyBox" from 12

Docker-run containers using the network of overlay mode created in swarm mode

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.