![docker network hostname docker network hostname](https://www.appdynamics.com/wp-content/uploads/2018/05/k5fwtjewnq0e_4b6-p-faqgne1pz9nthhceuqgezwkbibp7mptpuqgwez1sf51pckc4dnbzmwdgb6d4dqizgabn4syfdqtm4vg2pdmndb1uy6nxsonwwxemdlsibcslm2qm52r__.png)
DOCKER NETWORK HOSTNAME SOFTWARE
DOCKER NETWORK HOSTNAME UPDATE
When using the ”–link” option, docker creates a new entry in the containers /etc/hosts file with the IP address and name provided by the ”link” directive.ĭocker will also update this file when the remote container (here appsrv1) IP address is changed (IE when restarting the container). Then let’s start up our rsyslogd container:ĭocker run -detach -name rsyslogd -hostname=rsyslogd \ĭocker run -detach -name appsrv1 -hostname=appsrv1 demo:appsrvĪnd finally, let’s start HAProxy, with a docker link to appsrv1:ĭocker run -detach -name haproxy -hostname=haproxy \ĭocker links, /etc/hosts file updated and DNS To make it simpler, let’s restart docker first, so our container IPs are predictible: I consider appsrv container as yours: it’s your application.ĭocker assign IPs to containers in the order they are started up, incrementing last byte for each new container. Rsyslogd server pre-configured for HAProxyĭocker build -t blog:haproxy_dns ~/tmp/haproxy/blog/haproxy_docker_dns_link/blog_haproxy_dns/ĭocker build -t blog:rsyslogd ~/tmp/haproxy/blog/haproxy_docker_dns_link/blog_rsyslogd/.HAProxy docker container with DNS resolution.They can be build from the following Dockerfiles: haproxy: our load-balancer, which must follow-up appsrv1‘s IPįirst, we need rsyslogd and haproxy containers.appsrv1: our application server, which may be restarted at any time.rsyslogd: where HAProxy will send all its logs.In this article, we’ll start up 3 containers: The IP address associated to docker0 will be used to export some services. | | | HAProxy | | appsrv1 | | rsyslogd | | | all containers run in the subnet 172.16.0.0/16.A docker0 network interface, with IP 172.16.0.1.The diagram below shows how docker runs on my laptop: The version of docker used for this article is 1.8.1 (very important, since docker’s default behavior has changed in 1.9.0…) HAProxy, webapp and docker diagram This blog article aims at giving a first answer to this question.
DOCKER NETWORK HOSTNAME HOW TO
When used in production together with HAProxy, devops teams face a big challenge: how to followup a container IP change when restarting a container?
![docker network hostname docker network hostname](https://user-images.githubusercontent.com/1132397/62431327-a7807580-b6f4-11e9-9c54-d3864a6d4042.png)
Docker is a nice tool to handle containers: it allows building and running your apps in a simple and efficient way.