‫The requirements for this assignment are very similar to the last assignment. You'll need to know how
‫to get into the shell of a container when you run it or after the fact.
‫And know some basics around Linux distributions and what's something like Ubuntu might be different
‫than Alpine or CentOS. And, of course, running a container. Then the basics of how DNS records might
‫work like what an alias record is or how to create one.
‫That would be handy because you're going to be doing some testing around DNS. For your next assignment,
‫we're going to do some DNS round robin testing.
‫And if you're not familiar with DNS round robin is the concept that you can have two different hosts
‫with DNS aliases that respond to the same DNS name.
‫When you think about something like google.com obviously they've got more than one server.
‫So, one of the techniques that big companies use to always make sure they're up 24/7 is to employ DNS
‫round robin as part of their strategy so that there's actually multiple IP addresses in DNS records
‫behind the name you're using on the Internet.
‫Now in containers it actually gets a lot simpler.
‫Here we've actually got this feature in Docker Engine 1.11 and newer.
‫We've had a feature where if we create a custom network, we can actually assign an alias so that multiple
‫containers can respond to the same DNS name.
‫So for this one you're going to first create a new virtual network, call it whatever you want, and you're
‫going to set up two containers using a new image called Elasticsearch; and, specifically the version
‫2 of Elasticsearch.
‫So Elasticsearch isn't really a part of this course, but it's becoming a popular data store for... well really
‫just for search.
‫Hence the name.
‫Right.
‫So it's actually in a JSON format when you hit it from curl. So what we're going to do is we're going
‫to actually use it as a quick test because it's really easy to use in this scenario.
‫You want to research and check out the --net-alias command.
‫That's actually an option for docker run.
‫And when you start a container, you're going to tell it, I want another DNS alias to call this container
‫by, not just its container name.
‫This gets around a little problem that if you've ever used Docker in production, and you've started
‫to add a lot of containers, you realize you can't add multiple containers with the same name...
‫but how can I resolve DNS on my networks and maybe have the same app installed twice.
‫Maybe I've got a dev and a test environment on the same server and I need to, in both of those, call something
‫search in the DNS.
‫Well this is how you get around that limitation.
‫You can just keep adding aliases to your containers when creating them and you'll find out that they
‫can actually respond just like a DNS round robin does.
‫So once you've started those up, you can use the alpine image to do an nslookup, and that will
‫simply return to you a list of the DNS addresses for the name search.
‫And remember on that one you're going to have to make sure that it's signed with the --net to
‫the same network that you assigned to the first two containers.
‫Then after you've got both of those containers resolving to the same search name, you can actually
‫use the curl command to get a quick output of the elasticsearch server.
‫And this is a little trick with elasticsearch and why it's good to use in this demo. The curl command
‫actually comes with a CentOS image.
‫So it's easy to just use CentOS in this case instead of Alpine or Ubuntu and also elasticsearch
‫runs on port 9200.
‫And since it returns an easy, short JSON result, it's quick and easy for this test.
‫And lastly elasticsearch actually gives random names to itself inside its configuration when it first
‫starts up.
‫It's kind of similar to how containers give themselves random names if you don't specify.
‫What we can do here is if you keep running that curl command over and over you'll actually notice
‫that the output...even though you're using the same search DNS name to do a curl on... you'll actually flip
‫back and forth between the two different elasticsearch containers.
‫It might not be even.
‫It's not going to exactly be one, then the other, then the first, then the second one. It's going to be a
‫little off, because that's kind of one of the downsides of DNS round robin, it's not a true load balancer.
‫I like to kind of call it the poor man's low balancer.
‫But in this case it'll give you a sense of how to use a virtual network with DNS built in to make it
‫easy to use multiple containers that have the same name.
‫And as always you can skip to the next lecture to watch me walk through it as I would do it.
‫But you might get to the same end result with typing slightly different commands or launching your containers a
‫slightly different way.