Docker
/Intermediate
Container Communication
Definition
The architectural patterns and DNS mechanisms by which multiple isolated containers discover and send data to each other securely.
Explain Like I'm New
How the front-end finds the back-end. Instead of hardcoding messy IP addresses, containers use a built-in phone book to call each other by name.
Real World Example
A React container needs to fetch data from the API container. Instead of writing `fetch('http://192.168.1.5:3000')`, the developer writes `fetch('http://api-service:3000')`. Docker's internal DNS intercepts the request and instantly resolves `api-service` to the correct internal IP.
Common Use Cases
- •Microservices
- •Database connections
Interview Questions
basic
- Is it a good idea to hardcode Container IP addresses into your application code?
intermediate
- Why does a web browser on your laptop fail if it tries to hit `http://api-service:3000`?