liveBook · Manning

Service discovery

As explained in Learn Docker in a Month of Lunches, Second Edition

Service discovery is the technique of dynamically locating a service and obtaining the network address needed to communicate with it.

Service discovery dynamically locates a service and provides the network address needed to communicate with it. In Docker Compose, containers on the same Docker network can use service names instead of unstable container IP addresses. Docker’s built-in DNS resolves a container name to its current IP address, and forwards non-container names to the host’s normal DNS. section 7.3

The practical workflow is:

  • Start or scale the Compose application. section 7.3
  • Connect to a running web container using its Linux or Windows shell. section 7.3
  • Run nslookup against a service name such as accesslog or iotd; one container returns one address, while a scaled service can return multiple addresses. section 7.3
docker container rm -f image-of-the-day-accesslog-1
docker compose up -d --scale iotd=3
# for Linux containers:
docker container exec -it image-of-the-day-image-gallery-1 sh
# for Windows containers:
docker container exec -it image-of-the-day-image-gallery-1 cmd
# inside the container session:
nslookup accesslog
nslookup iotd
exit

Practice service discovery by removing a container, scaling the application, entering the web container, and looking up both accesslog and iotd. section 7.3

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains Docker DNS, network resolution, scaling behavior, and verification commands without descending into DNS internals.
Examples
Demonstrates scaled iotd and accesslog services through nslookup inside the image-gallery web container.
What it assumes
Assumes basic containers and Docker Compose, while explaining container IP changes and DNS resolution directly.
What you can do after
Operate/configure Docker Compose services and verify name-based connectivity with nslookup.
How it connects
Connects Docker Compose, containers, Docker networks, DNS, IP addresses, and scaling.

Also explained in

Compare how 7 books explain service discovery →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.