Containers in the same docker network have access to exposed ports.
docker network create sample
docker run --net sample --name keys consul agent -server -client=0.0.0.0 -bootstrap
Consul's Dockerfile exposes 8500
, 8600
, and several more ports. To demonstrate, run another container in the same network:
docker run --net sample -ti alpine sh
/ # wget -qO- keys:8500/v1/catalog/nodes
Here the consul container is resolved from keys
, the name given in the first command. Docker provides dns resolution on this network, to find containers by their --name
.