DNS Round Robin test

Assignment

  • Ever 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 --net-alias search when creating them to give them 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 show

Solution

~> docker network create rr-test
b11209a6a2c4be25b51ac452fc01e23916d48a3a53f3242db8f4b6349e5d923c

~> docker container run -d --net rr-test --net-alias search elasticsearch:2
e3c5e657384c46290b66e3079fb9b223ec3feab13e7b3e5e42c952c6666dc07c

~> docker container run -d --net rr-test --net-alias search elasticsearch:2
c3ef386174abfe43c95e35c236facb101cda523c241d024d10d23c5e79ac4a67

~> docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                NAMES
c3ef386174ab        elasticsearch:2     "/docker-entrypoin..."   43 seconds ago       Up 41 seconds       9200/tcp, 9300/tcp   jovial_borg
e3c5e657384c        elasticsearch:2     "/docker-entrypoin..."   About a minute ago   Up About a minute   9200/tcp, 9300/tcp   loving_bose

~> docker container run --rm --net rr-test alpine nslookup search
nslookup: can't resolve '(null)': Name does not resolve

Name:      search
Address 1: 172.19.0.3 search.rr-test
Address 2: 172.19.0.2 search.rr-test

~> docker container run --rm --net rr-test centos curl -s search:9200
{
  "name" : "Paralyzer",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "sXRTU1nRR_Okthre2dUsMA",
  "version" : {
    "number" : "2.4.6",
    "build_hash" : "5376dca9f70f3abef96a77f4bb22720ace8240fd",
    "build_timestamp" : "2017-07-18T12:17:44Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.4"
  },
  "tagline" : "You Know, for Search"
}

~> docker container run --rm --net rr-test centos curl -s search:9200
{
  "name" : "Hercules",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "684pzu1TR9WouDz63lu0aQ",
  "version" : {
    "number" : "2.4.6",
    "build_hash" : "5376dca9f70f3abef96a77f4bb22720ace8240fd",
    "build_timestamp" : "2017-07-18T12:17:44Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.4"
  },
  "tagline" : "You Know, for Search"
}

~> docker container run --rm --net rr-test centos curl -s search:9200
{
  "name" : "Paralyzer",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "sXRTU1nRR_Okthre2dUsMA",
  "version" : {
    "number" : "2.4.6",
    "build_hash" : "5376dca9f70f3abef96a77f4bb22720ace8240fd",
    "build_timestamp" : "2017-07-18T12:17:44Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.4"
  },
  "tagline" : "You Know, for Search"
}

First time I got "Paralyzer" next time "Hercules" and third time "Paralyzer" again so I know that Round Robin is working properly

results matching ""

    No results matching ""