Containers are isolated. How do you connect a web server to a database? How do you communicate between containers on different servers? Docker networking has undergone a fundamental evolution.
Bridge, Host, Overlay¶
Bridge: User-defined bridge with DNS discovery. Containers see each other by name. Host: Shared network namespace, no isolation. Overlay: Multi-host via VXLAN; requires a KV store (Consul/etcd).
docker network create myapp-net
docker run -d --name db --network myapp-net postgres:9.4
docker run -d --name app --network myapp-net -e DB_HOST=db myapp:1.0
Security and tips¶
Separate networks for isolation: a frontend network (web + API gateway), a backend network (API + DB). Do not publish ports you do not need. Consider overlay with encryption.
Networking is key infrastructure¶
For local development use docker-compose networks; for production use overlay with Consul discovery.
Need help with implementation?
Our experts can help with design, implementation, and operations. From architecture to production.
Contact us