docker.server.osType contains linux

My understanding is that I can build Windows or Linux containers on a Windows host by switching the container type on the command line. However, when I try and assign a Linux docker build to the Docker build agent (running Windows), I get the incompatible build message:

Unmet requirements: docker.server.osType contains linux
This makes sense since the agent is Windows but I run a script to switch the containers to Linux before the build so this should be valid. I notice that even if I choose Linux containers and restart the build agent, it still reports Windows.
If I have understood correctly, this is a bug and the configuration checker for Docker should allow Linux and Windows docker builds to be compatible with a Windows build agent.

Hi Luke, 

as I remember Docker Service on Windows should be restarted each time you switch between Linux\Windows container. How do you do it before a build? 

Moreover, an agent reads available on machine tools and their configuration only on the startup. So, just to switch Linux\Windows containers and restart Docker service aren't enough, you need also to restart an agent. 

There is a related feature request in YouTrack (to check docker configuration before starting a build), please watch\vote for it to get all future updates.


I can switch using powershell, it can be done with DockerCli, which is on Windows: & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchLinuxEngine

Although the script does work, it seems to take longer running this from TeamCity than it does when running it directly on the VM (like 1 minute instead of a few seconds) but that is manageable.

As mentioned above, I did restart the agent and it didn't make any difference, it still reported Windows when set for Linux containers.

I don't think that issue you linked is related.

I was able to make the build work by using Powershell scripts instead of the docker built-in steps and that works fine, although obviously slightly messier. I can also add the Docker build feature to make sure it only runs on Docker agents and this also seems to work OK since it only checks for docker.version or whatever it must be the build steps themselves that are running the check incorrectly.

The Docker build step needs improving to specifically work in this scenario, otherwise I need to have two sets of build agents for Windows and Linux, which is expensive.



Hi Luke,

Thank you for the details. This indeed looks like a bug, but I'm unable to reproduce it on my side. 

Are you sure, that switching to Linux containers actually works? I'm asking because I found this thread on StackOverflow (and a couple of similar one on the docker forum). So, in the command line after you called the PowerShell script you can pull e.g., `ubuntu:latest` without any problems, am I right?

If yes, could you please provide more information about your installation? What Windows\docker versions do you use? It would be also great if you can provide the teamcity-agent.log covering the time when the agent is restarting and trying to detect installed on the machine tools. You can provide it here or create a new issue in our YouTrack


Please sign in to leave a comment.