Home > Operation and Maintenance > Docker > How do two different docker hosts access each other?

How do two different docker hosts access each other?

Release: 2020-03-31 10:05:39
Original
4884 people have browsed it

How do two different docker hosts access each other?

We all know that docker containers in the same host can access each other, so can docker containers in different hosts access each other?

The answer is yes, the solution is to add the network segment of the docker container on another host to the routing table in the host.

The existing host A is 192.168.124.51 and host B is 192.168.124.55. The specific steps are as follows:

1. Modify the network segment used by the docker container of one host (the default is 172.17.x.x)

2. Assume that the docker network segment has been modified. For example, the docker container in host A uses the 10.1.x.x network segment, and the docker in host B uses the 172.17.x.x network segment.

Add the routing table in A

sudo route add -net 172.17.0.0 netmask 255.255.0.0 gw 192.168.124.55
Copy after login

Add

sudo route add -net 10.1.0.0 netmask 255.255.0.0 gw 192.168.124.51
Copy after login

to host B. At this point, the containers in hosts A and B can access each other.

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How do two different docker hosts access each other?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template