How Docker saved my life
There's a project I'm working on, slowly but surely. The project itself doesn't matter yet, but I knew I wanted to carve out a new space on the internet (hence krystof.io was born) and revitalize some pieces of tech I haven't touched in a couple of years.
A standard internet goal
I work on a lot of back end systems in my career. Not a lot of public facing activities. The most I encountered in the realm of the public eye would have been hoverandsmile.com. Sadly, some bits of tech rotted around that and I doubt I could re-enable it if I wanted to. Enough media remains however that my instructional videos still get a few views now and then.
I wanted to share and track this project on the web. I knew I wanted my own site to do it because social media can be fine for updates and progress in bits and pieces, I need a dedicated space to actually make it happen. Even then, to get that setup, there's plenty of administrative tag-a-long requirements that make building a full internet (even a non-commerce one) presence a bit of a chore to setup in my semi-anal-retentive fashion. (On a side note, it looks like it only took three posts before the word anal gets scraped by site crawlers.)
Granted, I already had a VPS and mail server attached. Nginx was the web server in need of repair, after shutting down hoverandsmile everything was just sitting there. What version of WordPress was I using? Do I even want to use wordpress? Oh yeah, I do have some databases here, what were these tables for?
It took a few days to dust off those major components until I was ready for the more public facing pieces of the website. Still more questions. What format? What platform? What's changed in SSL configs, nginx configs, how did that reverse proxy stuff work again? Should I try this piece? Should I try that piece? Most of the time I just wanted to play around with something, or multiple types of the same thing. Installing, re-installing, re-wiring configurations, changing defaults, cleanup, all that jazz, just to try something out.
This year I purchased my first NAS for the home. A Synology unit that I've had great experience with thus far. Raided up the wazoo, I started poking around other bits of software it natively supported. That's where I first ran across Docker. While Synology's version isn't a full docker install, I knew I'd end up installing it on my VPS at some point to give it a spin.
What's up, Doc(ker)?
Visit the Docker Website for all the latest and greatest info. The What is Docker page has some great comparisons between Docker and OS virtualization. For the brief rundown version - Docker is your halfway point between running programs on your host PC and running a virtual OS on your PC. From the Docker Website:
Containers running on a single machine all share the same operating system kernel so they start instantly and make more efficient use of RAM. Images are constructed from layered filesystems so they can share common files, making disk usage and image downloads much more efficient.
So while you're not using a virtual OS on your Windows PC to run Ubuntu Linux with Docker, you are wrapping whatever software and associated installation tag-a-longs inside a container that's generally isolated from your host machine.
Essentially, I could try out different software components wrapped in docker containers, configure them with their own filesystem (Docker images), meta-data and commands (Dockerfiles and Docker Compose Files), and setup and tear down as many containers running as many different pieces of software as I desired. Want to try Ghost out real quick? Just download the official image and create a container. Boom! Instant ghost blog setup with minimal linking between that container and a database container (or a host database process if you want them hooked up that way). Want a quick nginx server for a separate rapid prototyping service? Boom! Done. With some very creative image work done by contributors, those images are often combined with PHP support, SSL support, and more to where it reminds me of LAMP, but even easier than that.
It doesn't mean that there's no effort to trying out different containers, configuring them and hardening them for production level, but for the quick and dirty just trying it out on the same basic host system... Docker has been amazing. It has saved me so much time and effort in getting this presence stood back up in an easily maintained and upgrade-able way that it's my go-to for evaluating and deploying software used to maintain this site and related applications.
Now, I don't need dynamic provisioning of containers to handle load for a small site, but I have played with some of the Docker Swarm tools and there's a lot of promising stuff out there. Just searching the Docker Hub for official and popular images to download and execute in your own container is fun.
While Docker is great, it's still evolving. There are security concerns, there are container linking and networking concerns, there are deployment concerns, there are other concerns. That's not to scare anyone away, it's just not a holy grail in a bottle (Nothing ever is).
What Docker has done for me lately
Docker, and some very excellent images built by the Docker community, has helped me get past one of the larger mental blocks that I often get when starting a project. I have a difficult time just diving in to the heart of the matter first. I like to get more background and foundation started beforehand. I like to make sure pieces will work all together before I consider moving on to the heart of it. I don't know if that means I'm a better integrator than a developer, but I do know that Docker has helped me get those pieces fitting and working together faster than I could have manually.
So for me, I'm looking at quick prototyping of applications and some infrastructure controls. For those applications that didn't have a dedicated docker image, I needed some sort of web server base image to use to install the application. If I didn't like the final result? Delete the container. No host config changes to undo or packages to remove. Beautiful. A couple of images I've found that I really liked creating containers from for quick prototyping of applications that didn't have containers themselves:
Jason Wilder's Reverse Nginx Proxy is a simple concept done well. Not only does it provide reverse proxy support to all these other different containers I'm trying out, it automatically links them to the proxy's nginx container configuration. If I remove the application I was trying out, the proxy, using Docker events and meta-data API, automatically removes it from the proxy. I can reconfigure, rebuild, and restart application containers all day and the proxy adapts accordingly. Brilliant work.
Richard Harvey's ngineered Nginx-PHP-FPM container is a go-to for that rapid prototyping for an application that doesn't have it's own Docker image ready to go. It supports and comes configured with PHP and NGINX installed and ready to rock, perfect for evaluating applications or building a quick nginx server that's compartmentalized for a specific task.
Wrap the nginx-php-fpm image behind the nginx reverse proxy image and you can rapidly develop, prototype, and evaluate software a hell of a lot more easily than you could by hand.
I may document more of how I've used Docker, as it has really simplified all those bits and pieces I was always having to drudge through before I could move on to the heart of the matter - like writing this post.