I create a go script who switch between IP linked to my eno1 interface.
In case my program perform a curl --interface "51.15.xx.xx" ...
and switch between my 3 IPs
Bellow my interface :
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether ac:1f:6b:27:xx:xx brd ff:ff:ff:ff:ff:ff
inet 51.15.xx.xx/24 brd 51.15.21.255 scope global eno1
valid_lft forever preferred_lft forever
inet 212.83.xx.x1/24 brd 212.83.154.255 scope global eno1
valid_lft forever preferred_lft forever
inet 212.83.xx.x2/24 brd 212.83.154.255 scope global secondary eno1
valid_lft forever preferred_lft forever
My program run perfectly when he run on host directly, he work too on docker run --network=host
.
But in production with a docker swarm (deployed on 1 node), i can't bind host network and my program can't run. I get the error: bind failed with errno 99: Address not available
I just want to bind host
network with local scope on a swarm service or allow my swarm service to bind host ip
PS: I already try to bind network host but when I execute docker stack deploy
, docker select a host
network with scope swarm.
Best regards
Did you publish a port when declaring your swarm service or stack ?
According to the documentation:
If your container or service publishes no ports, host networking has no effect.
Try to use a direct command to create service, for example:
Code
docker service create --network host caa06d9c/echo
Docker image does not expose any ports
Check
curl localhost:8080
Output
{
"method": "GET",
"path": "/",
"ip": "127.0.0.1"
}
So port attached to the host and can be accessed from any interfaces.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.