Comunicação do Docker entre várias máquinas.

Como os contêineres em máquinas diferentes se comunicam? (O VXLAN pode ver os detalhes no site oficial.)

 

 

 

Primeiro, os dois hosts podem se comunicar.

Rede de sobreposição do Docker. (O host de ponte nenhum é uma máquina única. A sobreposição é uma rede de várias máquinas)

Os dois hosts mais setentrionais com docker instalado são docker1 e docker2!

Então você precisa de uma ferramenta para armazenamento distribuído. (Isso é para garantir que o endereço IP não seja duplicado. Por exemplo, no host docker1, o ip de um dos contêineres é 172.17.0.2. Em seguida, você precisa garantir que o endereço IP de outro contêiner na outra máquina também possa ser 172.17.0.2. É 172.17.0.3 172.17.0.4. Portanto, é necessária uma ferramenta de armazenamento distribuído para garantir isso.)

Use etcd aqui

# Ambos os hosts estão instalados:

[Miller @ baixar docker4] $ LS 
Python - 3.7 . 7   Python - 3.7 . 7 .tgz v3. 4.7 
[Miller @ docker4 download] RM v3 $. 4.7  
[Miller @ baixar docker4] $ wget HTTPS: // github.com/ IO-ETCD / ETCD / Lançamentos / download / v3.4.7 / ETCD-v3.4.7-Linux-amd64.tar.gz 
- 2020 - 04 - . 11  18 é : 47 : 37 [ - HTTPS: // github.com/etcd -io / ETCD / releases / download / v3.4.7 / ETCD-v3.4.7-linux-amd64.tar.gz 
anfitrião Resolvendo github.com (github.com) ... 52,74 . 223,119
Conectando github.com (github.com) | 52,74 . 223,119 |: 443 ... conectado. 
Uma solicitação HTTP foi enviada e está aguardando uma resposta ... 302 
Localização encontrada : https: // github-production-release-asset-2e65be.s3.amazonaws.com/11225014/cd901e00-7419-11ea-88fc-732f4a7bec4f?X-Amz -Algorithm = AWS4-HMAC-SHA256 & X-Amz-Credencial = AKIAIWNJYAX4CSVEH53A% 2F20200411% 2Fus-leste-1% 2Fs3% 2Faws4_request & X-Amz-Data = 20200411T104738Z & X-Amz-expira = 300 & X-Amz-Assinatura = 879d4434d3aa1db5bcb75cf57c3d139c5ae98904941d1aa3a41ad656774a9766 & X-amz-SignedHeaders = hospedeiro & actor_id = 0 & repo_id = 11225014 & response-content-disposion = anexo% 3B% 20filename% 3Detcd-v3.4.7-linux-amd64.tar.gz &- 04 - . 11  18 é : 47 : 38 é - HTTPS: // github-production-release-asset-2e65be.s3.amazonaws.com/11225014/cd901e00-7419-11ea-88fc-732f4a7bec4f?X-Amz-Algorithm=AWS4 -HMAC-SHA256 & X-Amz- Credencial = AKIAIWNJYAX4CSVEH53A% 2F20200411% 2Fus-leste-1% 2Fs3% 2Faws4_request & X-Amz-Data = 20200411T104738Z & X-Amz-expira = 300 & X-Amz-Assinatura = 879d4434d3aa1db5bcb75cf57c3d139c5ae98904941d1aa3a41ad656774a9766 & X-amz-SignedHeaders = hospedeiro & actor_id = 0 & repo_id = 11225014 & resposta -content-disposion = anexo% 3B% 20filename% 3Detcd-v3.4.7-linux-amd64.tar.gz & response-content-type = application% 2Foctet-stream 
está resolvendo o host github-production-release-asset-2e65be.s3.amazonaws .com (github-production-release-asset-2e65be.s3.amazonaws.com) ...52,216 . 133.75 
Conectando GitHub -production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com) | 52,216 . 133.75 |: 443 ... conectado. 
A solicitação HTTP foi enviada, aguardando resposta ... 200 OK 
Comprimento: 17310840 (17M) [aplicativo / fluxo de octetos ] 
está sendo salvo em: "etcd -v3 . 4.7 -linux- amd64.tar.gz" 

100 % [== ==================================================== ==================================================== =======================>] 17 , 310 , 840   3 .38MB / s tempo 5.1s    

2020 - 04 - 11.  18 é : 47 : 45 ( 3,26 MB / S) - Salvo "ETCD-V3 4.7 -linux-amd64.tar.gz" [ 17310840 / 17310840 ])

[download do miller @ docker4] $ tar -zxvf etcd-v3.4.7-linux-amd64.tar.gz

[download do miller @ docker4] $ cd etcd-v3.4.7-linux-amd64 /

Em seguida, configure separadamente

[miller @ docker4 etcd-v3. 4.7 -linux-amd64] $ nohup ./etcd --name ' docker4 ' \
 > --initial-advertise-peer-urls ' http://192.168.42.22:2380 ' \
 > --listen-peer-urls ' http : //192.168.42.22: 2380 ' \
 > --listen-client-urls ' http://192.168.42.22:2379 ' \
 > --advertise-client-urls ' http://192.168.42.22:2379 ' \
 > - token de cluster inicial ' etcd-cluster ' \
 > - cluster inicial 'docker4 = http: //192.168.42.22: 2380, docker5 = http: //192.168.42.23: 2380 ' \
 > --initial-cluster-state ' new & '  
nohup: ignore a entrada e inclua a saída em " nohup.out "

 


[miller @ docker4 etcd -v3
. 4.7 -linux-amd64] $ nohup ./etcd --name ' docker5 ' \ > --initial-advertise-peer-urls ' http://192.168.42.23:2380 ' \ > --listen-peer-urls ' http : //192.168.42.23: 2380 ' \ > --listen-client-urls ' http://192.168.42.23:2379, http://127.0.0.1:2379 ' \ > --advertise-client-urls ' http : //192.168.43.23: 2379 ' \ > - token de cluster inicial ' etcd-cluster ' \ > - cluster inicial 'docker4 = http: //192.168.42.22: 2380, docker5 = http: //192.168.42.23: 2380 ' \ > --initial-cluster-state ' new & ' nohup: ignore a entrada e inclua a saída em " nohup.out "

 

Ouça a janela de encaixe que iniciará isso. Porque informe ao docker que usamos o etcd.

 

Karma encomendado

 

Acho que você gosta

Origin www.cnblogs.com/chengege/p/12682172.html
Recomendado
Clasificación