0
0
Dockerdevops~5 mins

Container DNS and service discovery in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is service discovery in container environments?
Service discovery is the process that allows containers to find and communicate with each other automatically without hardcoding IP addresses.
Click to reveal answer
beginner
How does Docker's embedded DNS server help containers communicate?
Docker provides an embedded DNS server that resolves container names to their IP addresses within a user-defined network, enabling containers to reach each other by name.
Click to reveal answer
intermediate
What is the role of Docker networks in service discovery?
Docker networks isolate containers and provide DNS-based service discovery so containers on the same network can find each other by container name.
Click to reveal answer
intermediate
Explain how to use container names for service discovery in Docker Compose.
In Docker Compose, services can reach each other by using the service name as a hostname because Compose creates a default network with embedded DNS resolving service names.
Click to reveal answer
intermediate
What happens if containers are not on the same Docker network regarding DNS resolution?
If containers are on different Docker networks, they cannot resolve each other's names via Docker's embedded DNS, so service discovery by name will fail unless external DNS or other methods are used.
Click to reveal answer
What does Docker's embedded DNS server do?
AManages container storage volumes
BBlocks network traffic between containers
CAssigns static IP addresses to containers
DResolves container names to IP addresses within a Docker network
How can containers communicate by name in Docker Compose?
ABy using the service names as hostnames
BBy using IP addresses only
CBy configuring external DNS servers manually
DBy sharing the same storage volume
What is required for Docker containers to resolve each other's names automatically?
AThey must have static IP addresses
BThey must use host networking mode
CThey must be on the same Docker network
DThey must run on the same physical host
If two containers are on different Docker networks, what happens when one tries to resolve the other's name?
AThe containers communicate through the host network
BThe DNS resolution fails
CThe containers share the same IP address
DThe containers automatically connect
Which Docker command creates a user-defined network that supports service discovery?
Adocker network create my-network
Bdocker volume create my-network
Cdocker run --network=host
Ddocker build my-network
Describe how Docker's embedded DNS and user-defined networks enable service discovery between containers.
Think about how containers find each other without hardcoded IPs.
You got /4 concepts.
    Explain why service discovery might fail if containers are on different Docker networks and how to fix it.
    Consider Docker's network isolation and DNS scope.
    You got /4 concepts.