There are also two servers: Preparation: Set the hostname of the container consul: kv type storage database (key:value) On docker01 and 02: vim /etc/docker/daemon.json { "hosts":["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"], if this line is changed, you need to modify your docker configuration file "cluster-store": "consul://10.0.0.11:8500", "cluster-advertise": "10.0.0.11:2376" You can write your own IP address on the other machine. vim /etc/docker/daemon.json vim /usr/lib/systemd/system/docker.service Change the line ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock to this line. You need to change systemctl daemon-reload on both machines. systemctl restart docker On docker01: docker run -d -p 8500:8500 -h consul --name consul progrium/consul -server -bootstrap This command is done after setting the host name of the container [root@docker1 centos_zabbix]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 10.0.0.11:5000/kode v2 6914fda5fd44 4 hours ago 502MB kode v2 6914fda5fd44 4 hours ago 502MB 10.0.0.11:5000/centos6.9_nginx_ssh v3 92b1087df3f5 13 hours ago 431MB centos6.9_nginx_ssh v3 92b1087df3f5 13 hours ago 431MB centos6.9_nginx_ssh v2 6307e23ee16d 13 hours ago 431MB <none> <none> b94c822488f9 13 hours ago 431MB centos6.9_nginx_ssh v1 f01eeebf918a 13 hours ago 431MB <none> <none> 54167f1d659b 13 hours ago 431MB <none> <none> 71474e616504 13 hours ago 430MB centos6.9_ssh v2 03387f99f022 14 hours ago 307MB <none> <none> 82d0e9ce844b 14 hours ago 195MB kode v1 c0f486ac58fe 15 hours ago 536MB progrium/consul latest 09ea64205e55 4 years ago 69.4MB Here is [root@docker1 centos_zabbix]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1016753ee64d progrium/consul "/bin/start -server …" 4 minutes ago Exited (255) 3 minutes ago 53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp consul Last visited on the page: 2) Create an overlay network docker network create -d overlay --subnet 172.16.1.0/24 --gateway 172.16.1.254 ol1 This network segment cannot be the same as the host machine, and you can execute this command on any machine. Check the container's network to see if overlay appears. [root@docker1 shell]# docker network ls NETWORK ID NAME DRIVER SCOPE e480a4fe5f4b bridge bridge local 0a3cbfe2473f host host local 4e5ccdc657e1 macvlan_1 macvlan local aab77f02a0b1 none null local 8ae111afded7 ol1 overlay global 3) Start container test On one machine: docker run -it --network ol1 --name test01 centos6.9_ssh:v2 /bin/bash On another machine: docker run -it --network ol1 --name test02 centos6.9_ssh:v2 /bin/bash After that, you can connect between test01 and test02 After that, you can connect between test01 and test02 Real principle: Each container has two network cards, eth0 for communication between containers, and eth1 for container access to the external network The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue2.x configures routing navigation guards to implement user login and exit
Preface This article introduces a simple BAT scri...
Table of contents Install vim plugin manager Add ...
Use Nginx to build Tomcat9 cluster and Redis to r...
No matter you are installing Windows or Linux ope...
I have recently learned web development front-end...
How to deploy Oracle using Docker on Mac First in...
Table of contents vue - Use swiper plugin to impl...
Table of contents Preface What is Hot Change Coco...
When the submenu of the navigation bar is generat...
Recently I saw a barrage effect on B station call...
This article example shares the specific code of ...
Preface There are many devices nowadays, includin...
1. Cleaning before installation rpm -qa | grep jd...
Since the problem occurred rather suddenly and th...
Based on daily development experience and relevan...