3. Dezember 2018
Voting Docker-Swarm-style and how it helped me at NAV TechDays
At NAV TechDays 2018 I was lucky enough to host two 1-day workshops and a session around Docker on Windows and Business Central on Docker. It really was great fun but during the first day of my workshop I noticed that getting feedback on when people were ready with the current topic wasn’t easy. But I remembered a small voting app that I had seen on play-with-docker.com and thought that it should be not so difficult to adapt it to my needs. After this went well, I even used in my session to get feedback on my agenda with a couple hundred people voting in a timespan of probably less than thirty seconds.
During the breaks at my workshop I quickly spun up the voting app using a Docker Swarm as explained here. Adjusting the sample app to show „I am done“ vs. „I am still working“ instead of „cats“ vs. „dogs“ was quite easy and with that I had a good way of gathering progress feedback. As my session on the last day was in the very last slot before the closing keynote and after lunch, I decided to keep the audience awake by asking them for feedback on the order of my agenda. For that I spun up three Azure VMs and adjusted the voting app a bit more to allow voting for my four agenda topics, but it also was quite quickly done. To see it in action, check the recording from my session where I introduce the voting here and when I check the result here.
Play with Docker
If you haven’t heard of play with Docker, I would encourage you to go to https://labs.play-with-docker.com/ for a quick introduction and then to https://training.play-with-docker.com/ for some training sessions using Docker. Play with Docker actually is a browser-based playground that allows you to start using Docker without installing or setting up anything, using Docker in Docker technology. The list of trainings is quite comprehensive and with the „try as you go“ nature, similar to what later Try.NET has started to provide, it is very easy to learn and understand Docker concepts.
Adjusting the voting app for my workshop
The first step was extremely easy as I just wanted to change the labels: I no longer wanted to vote for „cats“ vs. „dogs“ but for „I am done“ vs. „I am still working“. So I just changed those labels in the voting and in the result app as you can see here. Because that was so easily done, I didn’t bother to clone the repo and change that somewhere locally but instead used vim inside of the play with Docker sessions to adjust the application to my needs. Because those play with Docker sessions at some point time out, I also created custom Docker images with my version of the voting app and pushed them to the docker hub. After that all I had to do to get my flavor of the voting app was
- start a new session
- pull my code including the stack files which reference my images
- run that
This is exactly the same as described in the training, only using
https://github.com/tfenster/example-voting-app as clone URL.
Preparing the voting app for my session
In my session I had to allow four different voting possibilities, so I had a bit more to change as you can see here. Unfortunately for whatever reason the Github compare shows a lot more changes for the HTML / CSS parts, but I actually didn’t change that much. If you want to give it a try, just use the same commands again as in the training with
https://github.com/tfenster/example-voting-app as clone URL and switch to branch „four“ or just adjust docker-stack.yml to use
tobiasfenster/examplevotingapp_result:4 as images for
result respectively. To give it a bit more power (probably not needed but rather cheap if you only need it for 90 minutes…) and higher availability I created three Linux Azure VMs and took the same steps as in the training, now only on „real“ VMs.
Once more, Docker makes it so easy to set up and scale a non-trivial application consisting of six services, one of them replicated across multiple nodes. This even includes the Docker Swarm visualizer which generates the following overview of the application, in this case running on two nodes
I am already discussing repeat runs of my workshop and I definitely will be using the voting again!