What You'll Learn
Beginner
- How containers communicate on custom networks
- How Docker DNS resolution works
Default bridge has no DNS
On the default bridge, containers communicate by IP only. Use a custom network for DNS.Terminalbash
docker network create app-net
docker run -d --name web --network app-net nginx
docker run -d --name api --network app-net node:18
# api can reach web by name:
docker exec api curl -s http://webKey Takeaways
- Custom bridge networks have built-in DNS.
- Containers resolve each other by name, not IP.
- Create:
docker network create my-net - This is how Docker Compose works.
Comments
Comments
Post a Comment