Static IP docker containers for connecting two different hosts

you can change ip docker0 or provide a static IP address for docker containers, because by default docker containers have an ip range of 172.17.0.2/16, but my network 192.168.XX / 24 works in this situation on the server container, all containers can communicate on servers, but it was not possible to connect from another server.

+4
source share
3 answers

How to configure a cluster? Do you use Roy? If so, you need to use the backend to store k / v to provide communication between two containers hosted on different hosts. Is this what you intend to do, or do you want the host to communicate with the container on another host? Anyway, the solution is similar.

I am rewriting a tutu for Docker Swarm to pull it into my Swarm doc, you can take a look: https://www.auzias.net/en/docker-network-multihost/

Have a nice day!

+2
source

I answered a similar question here fooobar.com/questions/66399 / ...

The difference in your case would be to create netowrk from the 192.168.XX / 24 subnet, and then assign the desired ip addr in the container using -ip

0
source

the problem can be fixed using --network=host
this will allow your container to use the host network. For direct access to your container, you can change the ssh port of the container and access your container with a specific port number.

0
source

Source: https://habr.com/ru/post/1620241/


All Articles