<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robb Manes</title>
    <description>The latest articles on DEV Community by Robb Manes (@robbmanes).</description>
    <link>https://dev.to/robbmanes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F22153%2F95d3b3bd-1025-4ac9-9b96-94ce9d1cb096.jpg</url>
      <title>DEV Community: Robb Manes</title>
      <link>https://dev.to/robbmanes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robbmanes"/>
    <language>en</language>
    <item>
      <title>What a Video Game for Kids can Teach you about Software Engineering and Infrastructure</title>
      <dc:creator>Robb Manes</dc:creator>
      <pubDate>Sun, 19 Sep 2021 17:39:25 +0000</pubDate>
      <link>https://dev.to/robbmanes/what-a-video-game-for-kids-can-teach-you-about-software-engineering-and-infrastructure-29i1</link>
      <guid>https://dev.to/robbmanes/what-a-video-game-for-kids-can-teach-you-about-software-engineering-and-infrastructure-29i1</guid>
      <description>&lt;p&gt;I'm an avid gamer.  I play almost everything, and most recently I've been getting in to automation games like &lt;a href="https://store.steampowered.com/app/526870/Satisfactory/" rel="noopener noreferrer"&gt;Satisfactory&lt;/a&gt; or &lt;a href="https://store.steampowered.com/app/427520/Factorio/" rel="noopener noreferrer"&gt;Factorio&lt;/a&gt;.  After hundreds of hours in building factories in these games my Steam recommendations decided to show me &lt;a href="https://store.steampowered.com/app/979120/Autonauts/" rel="noopener noreferrer"&gt;Autonauts&lt;/a&gt;, and at first glance I was a bit appalled at the recommendation.  It seemed very childish and the playground-toys theme turned me off of it for a while, until one day I decided to pick it up and, over the next one hundred hours of play, realized it was the absolute best simulation of &lt;em&gt;all&lt;/em&gt; of the facets of IT Infrastructure I've ever seen.&lt;/p&gt;

&lt;p&gt;Simulations of real-world engineering and software exist everywhere in video games these days.  I was shocked at how extensive you could make faux electronical devices in &lt;a href="https://www.minecraft.net/en-us" rel="noopener noreferrer"&gt;Minecraft&lt;/a&gt; when the Redstone update was introduced, and a quick search on your favorite web browser will show people have made entire in-game CPU'S and complex computational devices in massive feats of computer engineering - all within a game about surviving and crafting.&lt;/p&gt;

&lt;p&gt;There are quite a few &lt;em&gt;pure&lt;/em&gt; programming games out there; I love &lt;a href="https://www.zachtronics.com/" rel="noopener noreferrer"&gt;Zachtronics&lt;/a&gt; games, which between &lt;a href="https://store.steampowered.com/app/504210/SHENZHEN_IO/" rel="noopener noreferrer"&gt;Shenzen I/O&lt;/a&gt;, &lt;a href="https://store.steampowered.com/app/370360/TIS100/" rel="noopener noreferrer"&gt;TIS-100&lt;/a&gt;, and &lt;a href="https://store.steampowered.com/app/300570/Infinifactory/" rel="noopener noreferrer"&gt;Infinifactory&lt;/a&gt;, can satisfy my need for programming outside of work.  I'm a huge fan of pure logic games as well such as &lt;a href="https://store.steampowered.com/app/736260/Baba_Is_You/" rel="noopener noreferrer"&gt;Baba is You&lt;/a&gt;, which looks playful but carries a deep approach to puzzle solving utilizing rulesets.  This being said, the target audiences for these games are clearly those who enjoy logic puzzles and already have some experience in them, perhaps an older-than-teenager audience.&lt;/p&gt;

&lt;p&gt;Back to Autonauts.  I launched the game with the images I'd seen so far in mind; everything was blocky and cute, and everything had a smile on it in a preschool-wonderland sort of way.  Like any other "Survival Crafting" game, was put in an untamed area and had to scavenge for basic resources to begin the progression from humble vagrant to planetary tycoon as so many other games encourage the player to do.  I made a workbench with my own hands, made an axe, and started chopping down trees and refining logs into planks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgpcfhrok6bz12tfhbmx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgpcfhrok6bz12tfhbmx.jpg" alt="Welcome to the middle of nowhere, population you."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the initial work, the tooltips encouraged me to craft a workbench specifically to make robots, or "Bots".  I did so, and then used it to craft my first Bot, and then the true genius of Autonauts began to shine.&lt;/p&gt;

&lt;p&gt;Using my new Bot, I was able to "Teach" it to chop trees for me by simply mirroring the action.  As I did so, the Bot translated this into a &lt;a href="https://scratch.mit.edu/" rel="noopener noreferrer"&gt;Scratch-like&lt;/a&gt; language on-the-fly with simple instructions that I could click and drag, including the addition of loops or if/else statements with drop-down qualifiers.  It was very simple, and then after a few more Bots and a few more sessions of teaching and rearranging codeblocks, I had a fully automated forestry operation going, complete with re-planting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtubve7in9uemeqi8ish.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtubve7in9uemeqi8ish.jpg" alt="Look out new world, the gentle touch of automation is here."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, I realized I likely never had to chop down a tree by hand in this game again.&lt;/p&gt;

&lt;p&gt;Things began to quickly accelerate.  I had quarries of stone and clay worked by machine hands, courier networks delivering to a central warehouse, and teams of assemblers/crafters distributing tools such as axes, picks, and shovels to the various resource sites, each managed autonomously and independently in teams of Bots.  Bots need to be "recharged" by turning a crank, and while I did this by hand, after a hundred Bots were made I made a special team of Bots to turn the cranks on other Bots, removing all of the human intervention everywhere I could in a flurry of automation.&lt;/p&gt;

&lt;p&gt;Eventually, after certain milestones I received upgrades; I could now craft machines that made "Colonists" and with that came a lot of new technologies to dabble in such as Agriculture.&lt;/p&gt;

&lt;p&gt;I now had "Colonists" to take care of, babies spawned out of a machine that needed food, housing, and clothing.  I set up these teams quickly, creating Bot-tended fields of berries and lettuce, and setting up orchards of Apple trees.  I created a fishing team, catching and slicing up salmon, and fed everything to the colonist-babies I suddenly was responsible for.  My automatic empire grew to support these colonists, and in return colonists produce a resource called "Wuv" which really are just tokens you can put in a sort of Research Machine to advance your technological level, letting you build new machines and better Bots.  Eventually even the &lt;em&gt;colonists&lt;/em&gt; themselves leveled up, growing into having more and more needs, and I had to adapt previous teams of Bots and make entire new teams to hit the ever-shifting target of needs for these growing colonists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F72vms807ee67xze7bcu5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F72vms807ee67xze7bcu5.jpg" alt="Birds eye view of the craziness."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It wasn't until I had to do my first very-real upgrade problem of infrastructure that all of the similarities of my experience in IT, Development, and Infrastructure began to figuratively bash my head in.  The problem was this: I had a large number of entry-level Bots which are slow and have multiple drawbacks, but were otherwise working just fine.  I had intermixed teams of Bots of varying levels and effectiveness, and it was creating intermittent poor performance for one of my teams as sometimes there would be a surplus of materials and other times a drought as the different-level worker Bots performed tasks at different rates.  I sought to consolidate skill levels by upgrading teams to the new &lt;code&gt;Mk 2&lt;/code&gt; level of Bot, and decommission the old ones, and went about doing so.  There were a few hiccups, but I had felt I had everything under control until I scrolled to a side of my base and saw this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femg4wb1wlgn9k64hels2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femg4wb1wlgn9k64hels2.jpg" alt="Behold, the Salmon abomination."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is a tower of stacked and still wriggling salmon that is reaching the stratosphere.&lt;/p&gt;

&lt;p&gt;I couldn't find the problem immediately.  I went to the fishing teams, and couldn't see which unit was responsible for the salmon; I had just replaced my older Bots.  So then I realized I had switched the duty to "fetching" the salmon to my Kitchen team, which led me to the culprit; the sole "Salmon Fetcher" Bot had a "If crate of salmon is full" instead of "If crate of salmon is NOT full" clause which caused it to run once and then ponder what to do ever after.  Therefore, the fisher Bot just kept fishing, and piling the salmon on top of each other, forever.  I thought I had directly copied this code to fetch salmon from an older Bot but clearly I had changed something incorrectly in the course of my upgrade, and really had no way to know what was different.&lt;/p&gt;

&lt;p&gt;This isn't the only example I could make of this being a direct allegory to positions in DevOps, Product Manager, Development, QA, Support, or any really software infrastructure position.  The Colonists are really just customers who have the very-real shifting expectations of delivery as their needs are being met in various ways.  Upgrading my infrastructure was always a hassle, and I had to make decisions on when and where to impact my production based on what was most important to me at the time.  I had to decide which Services mattered most, and observe multiple failures to ensure that all edge-cases were caught lest suddenly there be unexpected downtime in production until the issue was caught, rectified, and prevented for the future.&lt;/p&gt;

&lt;p&gt;One specific, important example I'd like to share is when I had to shift my "services" from a monolithic model to a microservice model.  As my requirements and physical areas to access expanded, it became better to have resources not all made in my central "factory", so I undertook an effort to move certain types of goods to be made in different locations; tools would be built in the "tool" factory, food and such would be processed in a specific location, etc.&lt;/p&gt;

&lt;p&gt;There are so many examples of how this game is the perfect, most real-world example of working in IT that I can't list them all.  It is a children's learn-to-programming game that I found to be an excellent (and intensely fun) description of what working in IT Infrastructure is like, from a myriad of positions and roles which you have to take upon yourself.  The game has no real consequence of failure; your colonists/customers can't leave you or "die" (yet, the game has a new "survival" mode coming out apparently) so it's very forgiving, especially when you forget to feed your customers for a week or so.&lt;/p&gt;

&lt;p&gt;All in all, I'm overjoyed at finding this game, and I encourage everyone who's interested in this sort of thing to pick it up.  It seems fairly age appropriate for all levels, and it truly is the best &lt;em&gt;real&lt;/em&gt; simulation of my experience working in IT so far.  Bravo to the developers.  By the end of my 100 hours, I'd advanced decently far (I am a slow perfectionist in these games) but still have plenty to unlock, but am quite happy with my operation thusfar.  Perhaps this isn't your thing, but I found this to be truly an exceptional example of "what do I do for a living" in a gamified, simplified way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pv24881b1urflfayrlb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pv24881b1urflfayrlb.jpg" alt="Bots making bots."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;May you catch your bugs early and often, lest they pile up in a tower of wriggling salmon that pierces the heavens.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>games</category>
      <category>infrastructure</category>
      <category>engineering</category>
    </item>
    <item>
      <title>Running CoreDNS as a DNS Server in a Container</title>
      <dc:creator>Robb Manes</dc:creator>
      <pubDate>Sat, 09 Feb 2019 06:17:12 +0000</pubDate>
      <link>https://dev.to/robbmanes/running-coredns-as-a-dns-server-in-a-container-1d0</link>
      <guid>https://dev.to/robbmanes/running-coredns-as-a-dns-server-in-a-container-1d0</guid>
      <description>&lt;p&gt;If you've ever needed to or wanted to set up your own DNS server, then this is for you.  I recently found myself in possession of a Raspberry Pi, and instead of relying on my home router for DHCP and DNS, I decided to serve both from containers on the Pi, so I could resolve all of my hosts with their respective names when I VPN back to my network.  I intended to have all other requests forwarded to another server that weren't in my local network, but still service local systems with my customized hostnames.&lt;/p&gt;

&lt;p&gt;Lately I find myself working more and more with containers and OpenShift, a Kubernetes distribution from Red Hat (disclaimer, I work for Red Hat), and in upstream Kubernetes one of the DNS servers provided is &lt;a href="https://coredns.io/"&gt;CoreDNS&lt;/a&gt;.  I've been playing around with it for a while and thought I'd make this tutorial concerning how to launch it yourself, using the &lt;a href="https://hub.docker.com/r/coredns/coredns"&gt;CoreDNS provided container image&lt;/a&gt; on Docker Hub.&lt;/p&gt;

&lt;p&gt;I'd also like to note we're using a very, very small fraction of CoreDNS functionality here.  One of the outstanding things about CoreDNS is its customizability with plugins, and its direct integration with Kubernetes via said plugins makes it extremely powerful indeed.  Nonetheless, if DNS servers are new to you, or &lt;code&gt;bind&lt;/code&gt; or &lt;code&gt;unbound&lt;/code&gt; scares you a bit, maybe give CoreDNS for your personal needs.&lt;/p&gt;

&lt;p&gt;Without further ado, here's how I got it working.&lt;/p&gt;

&lt;p&gt;First, pull the container image down locally from Docker Hub.  If you're using Docker, you can do so like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# docker pull coredns/coredns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, we'll need to configure a &lt;code&gt;Corefile&lt;/code&gt;, which serves as the CoreDNS daemon's configuration file; there are many options that can be passed in here (which can be seen in the CoreDNS manual), but I will go through the example I used.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[~/containers/coredns] # cat Corefile 
.:53 {
    forward . 8.8.8.8 9.9.9.9
    log
    errors
}

example.com:53 {
    file /root/example.db
    log
    errors
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's go through the options of the &lt;code&gt;Corefile&lt;/code&gt; one-by-one.  It is important to note that each bracketed section denotes a DNS "zone", which sets the behavior of CoreDNS based on what is being resolved.&lt;/p&gt;

&lt;p&gt;First, note the initial bracketed section.  It begins with a &lt;code&gt;.:53&lt;/code&gt;, indicating that this zone is a global (with "." indicating all traffic), and it is listening on port 53 (udp by default).  The parameters we set in here will apply to all incoming DNS queries that do not specify a specific zone, like a query to resolve &lt;code&gt;github.com&lt;/code&gt;.  We see on the next line, that we forward such requests to a secondary DNS server for resolution; in this case, all requests to this zone will be simply forwarded to Google's DNS servers at &lt;code&gt;8.8.8.8&lt;/code&gt; and &lt;code&gt;9.9.9.9&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Second, we have another zone which is specified for &lt;code&gt;example.com&lt;/code&gt;, also listening on UDP port 53.  Any queries for hosts belonging in this zone will refer to a file database (similar to how bind does) to do a lookup there; more on that momentarily.  As an example, a query to "server.example.com" will bypass the global zone of "." and fall into the zone which is servicing "example.com", and using the &lt;code&gt;file&lt;/code&gt; directive the database file will be referenced to find the proper record.&lt;/p&gt;

&lt;p&gt;That's all there is to this &lt;code&gt;Corefile&lt;/code&gt;, for a simple forwarding DNS server which also serves local clients with hostnames.  Now we have to make that DNS database file we referenced, &lt;code&gt;example.db&lt;/code&gt;, and fill it with our hosts.&lt;/p&gt;

&lt;p&gt;Although this isn't a DNS primer, I will go over how this file works.  There are two main records at play here, and I'll discuss a third; they are SOA, A, and CNAME DNS records which will make up our DNS configuration.&lt;/p&gt;

&lt;p&gt;Initially, we &lt;em&gt;must&lt;/em&gt; configure an &lt;code&gt;SOA&lt;/code&gt; record, or a "Start of Authority" record.  This is the initial record used by this DNS server in this zone to declare its authority to the client which is making a query, and we must begin the file with it.  Here is an example SOA record which can be used in this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com.        IN  SOA dns.example.com. robbmanes.example.com. 2015082541 7200 3600 1209600 3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To go over each section individually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;example.com.&lt;/code&gt; refers to the zone in which this DNS server is responsible for.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SOA&lt;/code&gt; refers to the type of record; in this case, a "Start of Authority"&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dns.example.com&lt;/code&gt; refers to the name of this DNS server&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;robbmanes.example.com&lt;/code&gt; refers to the email of the administrator of this DNS server.  Note that the &lt;code&gt;@&lt;/code&gt; sign is simply noted with a period; this is not a mistake, but how it is formatted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;2015082541&lt;/code&gt; refers to the serial number.  This can be whatever you like, so long as it is a serial number that is not reused in this configuration or otherwise has invalid characters.  There are usually rules to follow concerning how to set this, notably by setting a valid date concerning the last modifications, like &lt;code&gt;2019020822&lt;/code&gt; for February 08, 2019, at 22:00 hours.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;7200&lt;/code&gt; refers to the Refresh rate in seconds; after this amount of time, the client should re-retrieve an SOA.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;3600&lt;/code&gt; is the Retry rate in seconds; after this, any Refresh that failed should be retried.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1209600&lt;/code&gt; refers to the amount of time in seconds that passes before a client should no longer consider this zone as "authoritative".  The information in this SOA expires ater this time.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;3600&lt;/code&gt; refers to the Time-To-Live in seconds, which is the default for all records in the zone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once we've written our &lt;code&gt;SOA&lt;/code&gt; to our liking, we can add additional records for each of our hosts we wish to resolve.  I assign my IP addresses with static DHCP leases for certain MAC addresses, so to do so I first added the DNS server, so it can resolve to itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dns.example.com.    IN  A   192.168.1.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An &lt;code&gt;A&lt;/code&gt; record indicates a name, in this case &lt;code&gt;dns.example.com&lt;/code&gt;, which can be canonically mapped directly to an IP address, &lt;code&gt;192.168.1.2&lt;/code&gt;.  If I add another &lt;code&gt;A&lt;/code&gt; record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;host.example.com.   IN  A   192.168.1.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I can then assign a &lt;code&gt;CNAME&lt;/code&gt; record to it, which will serve as an "alias" of sorts, directing traffic back to &lt;code&gt;host.example.com&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server.example.com. IN  CNAME   host.example.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can add as many entries here as you like, or look up different types of records to suit your needs.  I ended up with something basic, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com.        IN  SOA dns.example.com. robbmanes.example.com. 2015082541 7200 3600 1209600 3600
gateway.example.com.    IN  A   192.168.1.1
dns.example.com.    IN  A   192.168.1.2
host.example.com.   IN  A   192.168.1.3
server.example.com. IN  CNAME   host.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, when we're done with our DNS zone file and our &lt;code&gt;Corefile&lt;/code&gt;, we can stick them in the same directory and prepare to export them to a newly-running coredns container.  I stuck both of these files in a directory of &lt;code&gt;~/containers/coredns/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pwd
/home/robb/containers/coredns

$ ls
Corefile  example.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the container, the &lt;code&gt;coredns&lt;/code&gt; binary looks in the immediate directory its in for any file named &lt;code&gt;Corefile&lt;/code&gt;, and uses it as configuration.  Unfortunately, in the &lt;code&gt;coredns/coredns&lt;/code&gt; image we pulled from Docker Hub, it is located in the root directory of &lt;code&gt;/&lt;/code&gt;, which can't be mounted as a volume.  We'll need to manually pass our &lt;code&gt;Corefile&lt;/code&gt; and ensure that the &lt;code&gt;file&lt;/code&gt; directive in our zone of &lt;code&gt;example.com:53&lt;/code&gt; is a direct path in the container to the DNS zone database file.  To do this, I mapped them to &lt;code&gt;/root&lt;/code&gt; in the container and passed the &lt;code&gt;-conf&lt;/code&gt; option which allows a user to specify the path to a Corefile; this is the command I used to launch my CoreDNS container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# docker run -d --name coredns --restart=always --volume=/home/robb/containers/coredns/:/root/ -p 53:53/udp coredns/coredns -conf /root/Corefile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, I made sure my container was running without issues by checking the logs and &lt;code&gt;docker ps -a&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                        NAMES
8a6c9a5c0538        coredns/coredns     "/coredns -conf /roo…"   About an hour ago   Up About an hour    53/tcp, 0.0.0.0:53-&amp;gt;53/udp   coredns

# docker logs coredns
.:53
example.com.:53
2019-02-09T04:50:24.060Z [INFO] CoreDNS-1.3.1
2019-02-09T04:50:24.061Z [INFO] linux/arm, go1.11.4, 6b56a9c
CoreDNS-1.3.1
linux/arm, go1.11.4, 6b56a9c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then query our server with &lt;code&gt;dig&lt;/code&gt; from a client in the same subnet to make sure it's working as intended.  My DNS container is running on a host with an IP of &lt;code&gt;192.168.1.2&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ dig @192.168.1.2 host.example.com

; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.11.3-1ubuntu1.3-Ubuntu &amp;lt;&amp;lt;&amp;gt;&amp;gt; @192.168.1.2 host.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 30400
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 9faccdae88cb6576 (echoed)
;; QUESTION SECTION:
;host.example.com       IN  A

;; ANSWER SECTION:
host.example.com    0   IN  A   192.168.1.3

;; Query time: 3 msec
;; SERVER: 192.168.1.2#53(192.168.1.2)
;; WHEN: Fri Feb 08 23:01:22 MST 2019
;; MSG SIZE  rcvd: 93
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And just like that, we have an easy-to-configure and maintain CoreDNS configuration running!  Thusfar, I have been using &lt;code&gt;docker restart&lt;/code&gt; to reload the container and re-read the &lt;code&gt;Corefile&lt;/code&gt; and DNS zone file, but you should absolutely be aware of the &lt;a href="https://coredns.io/plugins/reload/"&gt;reload&lt;/a&gt; plugin to CoreDNS that removes the need to restart the container.&lt;/p&gt;

&lt;p&gt;That's a very basic introduction to CoreDNS, and I hope you get some good usage out of this great DNS daemon.&lt;/p&gt;

</description>
      <category>dns</category>
      <category>coredns</category>
      <category>container</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
