Windows docker containers for TeamCity Build Agents

I have been using TeamCity for a few years now, primarily as a build tool for some of our platforms at work.  However, because I like to have a sandbox in which to play, I have been hosting an instance of TeamCity at home for roughly the same amount of time. 

At first, I went with a basic install on a local VM and put the database on my SQL Server, and spun up another VM (a GUI Windows Server instance) which acted as my build agent.  I installed a full-blown copy of Visual Studio Community on the build agent, which provided me the ability to pretty much run any build I wanted.

As some of my work research turned me towards containers, I realized that this setup is probably a little to heavy, and running some of my support systems (TeamCity, Unifi, etc) in docker makes them much easier to manage and update.

I started small, with a Linux (Ubuntu) docker server running the Unifi Controller software and the TeamCity server containers.  Then this blog, which is hosted on the same docker server.  And then, as quickly as I had started, I quit containerizing.  I left the VM with the build agent running, and it worked. 

Then I got some updated hardware, specifically a new hypervisor.  I was trying to consolidate VMs onto the new hypervisor, and for one reason or another, the build VM did not want to move nicely.  Whether the image was corrupt or what, I don’t know, but it was stuck.   So I took the opportunity to jump into Docker on Windows (or Windows Containers, or whatever you want to call it).

I was able to take the base docker image that JetBrains provides and add the MSBuild tools to it. That gave me an image that I could use to run as a TeamCity Build agent. You can see my Dockerfile and docker-compose.yml files in my infrastructure repository.






4 responses to “Windows docker containers for TeamCity Build Agents”

  1. Ville Avatar

    Where did your infrastructure repository disappear? It wasn’t on github anymore. I’d like to take a look at it. 🙂

    1. Matt Avatar

      I updated the link in the post to a sanitized public version. Reading over it, the install-script is a bit old, it might need updated with the latest .Net Core and Node installers.

  2. adam Avatar

    stumbled upon this and was saddened to see that your repo link to infrastructure-sanitized is still 404 on github :/

    1. Matt Avatar


      I’ve moved away from TeamCity in favor of Azure DevOps with a self-hosted agent. A lot of my infrastructure repository was centered on docker-compose files, but now it’s just Helm value files. As those are mostly secrets, it’s difficult to sanitize and make any real sense of it.

      That said, if there’s something specific you are looking for, I can share it as a Gist.

Leave a Reply

Your email address will not be published. Required fields are marked *