# Name resolution not working with docker containers

**URL:** <https://discourse.haproxy.org/t/name-resolution-not-working-with-docker-containers/5963>\
**Category:** Help!\
**Created:** [November 24, 2020, 10:50am UTC](https://discourse.haproxy.org/t/name-resolution-not-working-with-docker-containers/5963 "2020-11-24T10:50:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mason](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Mason](https://discourse.haproxy.org/u/Mason)\
**Post date:** [November 24, 2020, 10:50am UTC](https://discourse.haproxy.org/t/name-resolution-not-working-with-docker-containers/5963/1 "2020-11-24T10:50:20Z")

</div>

I have installed HAproxy on two vagrant VM in virtualbox (both debian buster, on bridged network connection) and has setup (installed on the VM) keepalived to manage a single VIP. I am running two nginx docker containers on each machine. When I use the IP address for the ‘backend’ everything works as it should.  
When I use the hostname of the container HAproxy says

```auto
Nov 16 21:12:05 buster haproxy[24426]: [ALERT] 320/211205 (24426) : parsing [/etc/haproxy/haproxy.cfg:48] : 'server server1' : could not resolve address 'nginx1'.
Nov 16 21:12:05 buster haproxy[24426]: [ALERT] 320/211205 (24426) : parsing [/etc/haproxy/haproxy.cfg:49] : 'server server2' : could not resolve address 'nginx2'.

```

## Docker setup

```
docker network create web-net
docker run --name nginx1 --hostname nginx1 --network web-net -d nginxdemos/hello
docker run --name nginx2 --hostname nginx2 --network web-net -d nginxdemos/hello

```

## HAproxy configuration

```
global
    log /dev/log local0
    log /dev/log local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    log global
    mode http
    option httplog
    option dontlognull
    timeout connect 5000
    timeout client 50000
    timeout server 50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

resolvers docker
    nameserver dns 127.0.0.11:53

frontend http-in
    bind 192.168.100.200:80 # VIP
    default_backend servers

backend servers
    balance roundrobin
    server server1 nginx1:8080 check resolvers docker resolve-prefer ipv4
    server server2 nginx2:8080 check resolvers docker resolve-prefer ipv4

```

If I put the IP address of the nginx containers, instead of name then everything is fine.  
Can someone point me why the name resolution is not working correctly ? I tried the docker interface address. Any point to debug it correctly ?

Thank you.
