note use nslookup search. with latest alpine image or use older image like alpine:3.10

requirements

  • know host to use -it to get shell
  • understand basics of different distros (ubuntu vs. centos)
  • know how to run a container
  • understand basics of dns records

assignment

  • since docker engine 1.11 we can have multiple containers on a created network respond to the same dns address
  • create a new virtual network (default bridge driver)
  • create two containers from elasticsearch:2 image
  • research and use --network-alias search when creating them to give an additional dns name to respond to
  • run alpine nslookup search with --net to see the two containers list for the same dns name
  • run centos curl -s search:9200 with --net multiple times until you see both "name" fields change

answer

--network-alias list             Add network-scoped alias for the container
docker network create search_net
docker network ls
repeat 2 { docker container run -d --net search_net --network-alias search elasticsearch:2 }
docker container run --net search_net -it alpine watch nslookup search.
docker container run --net search_net -it centos curl -s search:9200