Connect nodes to an overlay network and the host network at the same time?
Hi All,
I would like to connect a container to both the host network and a custom overlay network.
Background
We have a cluster of custom services that appears to the outside world as a single functional unit. I deploy these with docker-compose, and have successfully used an overlay network to make it easy to configure the communication between these services.
One of these services (call it api-node) also needs to register itself with a different service that is not deployed using docker. That external service needs to communicate with the api-node, so the api-node gives the external service its ip address during registration.
Currently, all of these services are deployed within AWS, and there is only 1 docker container running per AWS instance.
Problem
Since the api-node is not part of the "host" network, the only ip addresses it has are within the docker network. It does not have access to the AWS hosts ip. Thus, the external service cannot call back to the api-node, since it is not part of the docker network.
Any ideas?
I would like to have the api-node join both the docker overlay network we created and the host network. But I don't think this is supported by docker-compose.
When I tried configuration like this in my service
networks:
- kiwinet
network_mode: "host"
I got an error like this
ERROR: 'network_mode' and 'networks' cannot be combined
When I tried configuration like this
...
networks:
- kiwinet
- hostnetwork
...
networks:
kiwinet:
driver: overlay
ipam:
driver: default
config:
- subnet: 11.0.0.0/16
hostnetwork:
driver: host
I got an error like this
ERROR: Error response from daemon: only one instance of "host" network is allowed
When I tried configuration like this
networks:
kiwinet:
driver: overlay
ipam:
driver: default
config:
- subnet: 11.0.0.0/16
hostnetwork:
external:
name: host
I got this error
ERROR: Network host declared as external, but could not be found. Please create the network manually using `docker network create host` and try again.
@sergey-safarov in swarm mode cap-add=NET_ADMIN is not supported and i can't run the overlay2host inside the container. how can i bypass it and run in inside the container?
overlay2host is designed to tun on host, not inside container.
@nadavsky @sergey-safarov Im trying to achieve the same thing, can you share your script with the veth name fix. Im trying to run a swarm service which needs to be connected to the swarm overlay and the host for outgoing traffic. If i understand correctly.. using a freeswitch container as a switch which bridges the host network that my container is in and the overlay which is connected to the freeswitch.. can i achieve this with swarm IPv6?
At present time overlay2host.sh script located at repo https://github.com/sergey-safarov/kazoo-configs-docker. Please create ticket and describe your issue in this repo.
excellent solution, also solve #919
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it had not recent activity during the stale period.
if it is possible to attach a container in swarm host network to also join an app overlay network, one can easily set up an internal Layer 7 load balancing that will provide high availability to the cluster without a need for an external load balancer.
Something like this below
