Let Containers update their DNS name
The Container no one could find
Docker is the new cool kid on the block when it comes to deploying applications. But as with every iteration in the IT this new kid does not only solves problems, it creates some new challenges. One these challenges is if you start moving to a docker based workflow for your services but have only very few containers (probably only one publicly available) to begin with. How do you make sure that it is reachable via a well known DNS name? There are rather complex solutions like SkyDNS etc. but they are only worth the effort if you have a huge load of containers running. What if you have one or two containers and you want to reach them under your domain? This is a problem we at least solved for Dynect users.
Welcome to Godyn
For our single and lonely containers we created a small golang application to update a record in Dynect. Why golang? Because its cool and new! Just kidding. golang gives us some nice high level abstractions for things like http client (which we need to make requests to Dynect) and has the nice feature that it compiles to a statically linked binary. So we can use this binary in every Docker container we create (probably even in a scratch based image). No need for a Python or Ruby runtime!
How does Godyn work?
Currently this is very very simple. We look up the first valid entry in
/etc/hosts in the container. At least on Triton this always contains the public IP. After that Godyn reads some environment variables to get the customer, username, password, zone and fqdn necessary to update a record in Dynect. The environment variables can be specified via the
docker run command. We tend to keep them in a file in a private repo and use
Ok, let me use it
Using Godyn is as simple as possible. Simply add the binary to your Docker image (of course it needs to be compiled for Linux-x86_64) and call it before you start your application. You could use a shell script wrapper for this for example. Then just specify the necessary environment variables (they are specified in the README.md in the Github repo) and your DNS record will be updated as soon as your container starts. Depending on how you start Godyn and your application an unsuccessfull record update will stop your container. This can be useful to notify you about a problematic DNS configuration in your Dynect zone.
Godyn is currently under development and it is plannend to add support for more managed DNS provider and for more complex DNS operations (like registering SRV entries for applications).