1

When we set an overlay network, we can use containers names to resolve container addresses. That works fine.

Can I use some other, custom network name?

For example, if my container name is foo, can I resolve it in my overlay network by bar?

igr
  • 10,199
  • 13
  • 65
  • 111

1 Answers1

4

Yes you can, with the option --net-alias (network-scoped alias for the container, proposal 18699):

docker run -itd --name foo --net-alias=bar --net mynetwork busybox

Any other container on the same network will be able to ping bar (which references foo)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanx! Do you know if it is possible to change alias while container is up? – igr Mar 16 '16 at 06:32
  • @игор I don't see that feature in the proposal. More generally, changing characteristics of a container *at runtime* is still very limited right now (cpu and memory resources, not much else yet: http://stackoverflow.com/a/34043844/6309) – VonC Mar 16 '16 at 07:11