Using Docker for Atomic Games Deployment

We’ve just run our sixth edition of the Atomic Games! The original version happened way back in 2015. For each edition, we’ve built a game board with core game logic. Games participants write AI players that compete against other teams’ solutions.

We’ve always written the game boards in Clojure, and that’s typically meant distributing a JAR file for students to launch the game. This year, we tried using Docker to distribute the game instead, and it went very well!

What’s Wrong with a JAR File?

Java used to boldly promise that you could “write once, run anywhere.” Of course, that rarely turns out to be true. We typically run into two problems every year:

  • Students often have incompatible Java versions installed on their laptops. Most have very little idea about what they have installed or how to switch to a different version. We often have teams wasting precious time trying to uninstall one Java version, download another, figure out what’s in their paths, etc.
  • Students often have port conflicts or firewalls that prevent our server from running. This is generally not a huge problem to solve, but by the time they’ve figured out the issue, done some googling, asked for help, etc., they’ve wasted precious time.

What We Did Instead

This year, we provided the game as a Docker container. The Dockerfile was quite simple to build:

FROM openjdk:13
COPY ./ao-game-server.jar /usr/src/ao-game/
WORKDIR /usr/src/ao-game
EXPOSE 8080
EXPOSE 1337
EXPOSE 1338
ENTRYPOINT ["java", "-jar", "ao-game-server.jar"]
CMD ["-w"]

We asked students to make sure that they had Docker installed prior to arriving at the event. With that out of the way, getting everyone up and running went quite smoothly. We had some concerns that folks would have trouble installing or using Docker, but we gave everyone example commands to work from, and that was enough to get everybody off to the races.

One really nice outcome is that it’ll be trivial for students to remove the game from their machines. We didn’t have to modify paths or versions or anything of that sort, so students won’t have any work to do to return to a previous state.

Another nice side effect is that we had an opportunity to introduce students to Docker (and hopefully demystify it a bit). It’s a great tool for developers to have in their toolboxes!

What We’ll Do Next Time

We’ve been thinking about cloud hosting the game next time around so that folks don’t have to bother installing it at all. Of course, the Docker approach worked so well that I’m starting to reconsider whether a cloud-hosted approach would be worth the effort. Some nice scripts to wrap the needed commands might be all we need to make this solution really useable for folks who are new to Docker.