A simple UI for managing local docker instances

I use Docker a lot for running the various web services I work on (either for myself or under contract). I'm a big fan of how, even when not using containers for deployment, it just simplifies so many things about building web services: I don't need to install a DB locally, I just run it in a container; I can test my code running in parallel using multiple container instances; I can install different potentially conflicting tool chains for different projects; and so forth.

Docker is also sufficiently lightweight I can often forget that I've got a mirror of some client's scaled web infrastructure running on my machine after I clock off, but not sufficiently lightweight I don't notice my battery draining quicker than I'd like when I have forgot to shut everything down. Unfortunately, on macOS at least, the default Docker UI doesn't indicate what the state of your local infrastructure is, making this a somewhat frequent occurrence for me.

To solve this, I've written a small status bar item, called Stevedore, that just simply indicates whether I've left any containers running (by having either an empty ship or one laden with containers on my menu bar) and has a drop down menu that then lets me quickly stop or start them. It's not the most impressive bit of engineering in the world, but it fixes a problem I have, so I thought I'd share it.

Screen Shot 2018-04-17 at 18.48.53 (2).png

Stevedore was also an excuse for me to play with Swift in anger for the first time in quite a while. Stevedore is a simple enough an app that it was easy to get started, but the Docker API being based on HTTP over Unix Domain Sockets meant I got to play with Dispatch IO and other bits of concurrency to keep it interesting to implement, and I wrote my own limitted HTTP parser to manage the docker channel: not because I should, but because it was a useful learning experience doing so in Swift. I really do miss playing with things like GCD, so it was good to exercise that bit of my brain again, and to learn just how far Swift has come since I last wrote any in production.

Whilst on the Bromium Mac team we wrote lots of gnarly code for macOS, it was almost exclusively in Objective-C, as we couldn't afford to keep playing catchup as Apple made incompatible changes to Swift each year. But now that I'm getting back to my own stuff, I'm keen to give Swift a serious go. Having built big/complicated products, I've learned the hard way that any language support you can get to make mistakes less likely is a good thing. This is why I like using Go for web services where possible, and why features of Swift like it's explicit function error returns make me very happy. At some point I'll write up what I think are the good/bad bits of Swift from that point of view, a bit like I did for Go a couple of months back.

Anyway, there's enough functionality in Stevedore I'm already using it daily, so if you think this might be of use to you, then head over to github where I've posted the source, or you can download a binary version here.