Load balancing spreads traffic across multiple service instances. Docker Compose provides a simple form by returning every container IP address for a service through DNS. section 7.3
Understand the practical limits of this approach:
- The application performs the DNS lookup and decides how to process multiple addresses. section 7.3
- Some applications use only the first returned address, while Docker changes the ordering between lookups to spread traffic. section 7.3
Scale a service
Run `docker compose up -d --scale iotd=3`, then execute `nslookup iotd` inside the web container. The lookup returns three addresses, one for each service container.
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 # now inside the container session run: nslookup accesslog exit
Use the command listing to scale the service and inspect its DNS responses from a Linux or Windows container shell. section 7.3













