Docker运行Kudu:主节点与TServer双向DNS连接问题及部署方案
Got it, let's break down how to solve this circular connectivity problem between Kudu's master and tserver containers. The root issue with your original setup is that Docker's legacy --link flag only enables one-way DNS resolution: your tserver can reach the master, but the master can't look up the tserver's hostname. Kudu requires full bidirectional communication—masters need to send instructions to tservers, and tservers need to report their status back to masters—so this one-way link won't cut it.
The Best Solution: Use a Custom Docker Network
Docker's custom networks automatically enable bidirectional DNS resolution between all containers on the same network, no messy --link flags required. Here's how to set it up step-by-step:
Create a dedicated Docker network for Kudu
This isolates your Kudu containers and ensures reliable DNS lookups:docker network create kudu-netStart the Kudu Master container attached to the network
We'll keep the hostname and port mappings, but replace--linkwith the network flag:docker run --name kudu-master \ --hostname kudu-master \ --network kudu-net \ --detach \ --publish 8051:8051 \ --publish 7051:7051 \ kunickiaj/kudu masterStart the Kudu TServer container on the same network
Now we just need to point the tserver to the master using its hostname (which will resolve automatically via the custom network):docker run --name kudu-tserver \ --hostname kudu-tserver \ --network kudu-net \ --detach \ --publish 8050:8050 \ --publish 7050:7050 \ --env KUDU_MASTERS=kudu-master:7051 \ kunickiaj/kudu tserver
Why This Works
- All containers on
kudu-netcan resolve each other's hostnames directly, regardless of startup order. - The master can now reach the tserver, and vice versa, eliminating the circular dependency issue.
Verify the Connection
To make sure everything's working:
- Ping the tserver from the master container to confirm DNS resolution:
docker exec -it kudu-master ping kudu-tserver - Check the tserver logs to confirm it connected to the master:
docker logs kudu-tserver | grep "Connected to master" - Check the master logs to confirm it registered the tserver:
docker logs kudu-master | grep "Registered new tablet server"
Alternative: Manual Hosts File Edits (Not Recommended)
If you absolutely have to use Docker's default bridge network (avoid this if possible), you'd need to manually add the tserver's IP to the master's /etc/hosts file and vice versa. But this is brittle—if containers restart, their IPs might change, breaking the connection. The custom network approach is far more reliable.
内容的提问来源于stack exchange,提问作者Danny Varod

