1

docker ps -a:

de09facf7c91        x/x:x   "/usr/bin/supervisord"   51 minutes ago      Up 24 minutes       8080/tcp                                                                           development-karl
226a1b80a233        x/x:x                                      "/usr/bin/supervisord"   2 hours ago         Up About a minute   0.0.0.0:80-84->80-84/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:1988->1988/tcp, 5672/tcp   haproxy

Started the container with this: docker run --name development-karl -h development-karl -d x/x:x

part of my haproxy.cfg:

backend karl_dev_backend
    balance roundrobin
    option forwardfor
    server      karl_dev development-karl cookie development-karl weight 1 maxconn 1024 check

Get the error in the haproxy logs:

[ALERT] 059/222244 (683) : parsing [/etc/haproxy/haproxy.cfg:67] : 'server karl_dev' : could not resolve address 'development-karl'.
[ALERT] 059/222244 (683) : Failed to initialize server(s) addr.

I don't know why it's not resolving?

EDIT, added answer info:

https://docs.docker.com/engine/userguide/networking/#the-default-bridge-network-in-detail:

Docker does not support automatic service discovery on the default bridge network. If you want to communicate with container names in this default bridge network, you must connect the containers via the legacy docker run --link option.

Legacy is pre version 1.10.

Legacy: https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/

More info on legacy linking: https://docs.docker.com/engine/userguide/networking/work-with-networks/#linking-containers-without-using-user-defined-networks

  • 1
    Did you start the haproxy container with --link development-karl? – jordanm Mar 1 '17 at 22:31
  • @jordanm I did not! I have the same setup on a separate server so I'm slightly confused :/ I suspect it has to do with docker and that it's "hiding" the containers? – Karl Morrison Mar 1 '17 at 22:39
1

I don't believe DNS discovery is enabled on the default docker bridge network. To connect multiple containers together with DNS discovery, create a network and attach both containers to that network:

docker network create proxy
docker network connect proxy haproxy
docker network connect proxy development-karl

You can also pass --net proxy to the docker run command instead of doing the docker network connect after the fact.

  • I see! I did a docker network inspect bridge however and they are all listed there? – Karl Morrison Mar 12 '17 at 11:46
  • Reread the first line of the answer please. – BMitch Mar 12 '17 at 11:54
  • Ah, I misread it. You are correct! I've updated your answer with the relevant links. – Karl Morrison Mar 12 '17 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.