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
?
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
)