Reload docker stack network configuration

回眸只為那壹抹淺笑 提交于 2019-12-11 06:56:17

问题


I have multiple docker stacks that are connected over the same network. If I restart one of the stacks the internal ip addresses of the related stack container seems to change. That results in wrong service name resolutions in other stacks and containers. It seems that the internal docker name service doesn't recognize the network change.

If try to access other containers with ping from a stack container shell by the service name (for example ping my_stack_my_container_name) I got a successful return from a wrong IP address. When I use the full container name instead (ping my_stack_my_container_name.134.134234234123) the return comes from the right IP.

Is there any way to trigger a reload of the stack networking/name service?


回答1:


are you sure it's not reloaded? check if the docker containers (that should connect to reloaded container) are not caching DNS query results. I had same issue in haproxy config and I placed following lines to force haproxy to hold values only for 1s:

resolvers docker
    # well known docker dns server address
    nameserver dns 127.0.0.11:53
    #HAProxy will hold name-ip mapping for 1s, so for each request new container ip will be resolved, balancing load
    hold valid 1s 

(...)

backend stackName_app_backend
    server stackName_app_service stackName_ServiceName:80 resolvers docker check


来源:https://stackoverflow.com/questions/50968697/reload-docker-stack-network-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!