6

I'm using Azure DevOps, and have a Linux build pipeline (ubuntu-16.04) setup that builds the code, starts containers with Docker Compose, then runs integration tests using the containers. This all works great.

Now I want to setup a Windows build pipline that does the same thing. However, with both the windows-2019 and win-1803 images, when I do docker stack up, I get this error message:

image operating system "linux" cannot be used on this platform

So, I guess Docker is installed in Windows mode, and thought to switch it to Linux containers using:

DockerCli.exe" -SwitchLinuxEngine

or

"%ProgramFiles%\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine

However, the DockerCli.exe executable doesn't seem to be installed at all.

The only 2 things I can think of are:

  1. Setup a self-hosted build agent
  2. Somehow start the required containers somewhere else

But both of these will be a lot of work to setup, which I really don't need, neither do I want the running costs, or the job of maintaining it.

Are there any workarounds to run Linux containers on hosted Windows build agents?

Cocowalla
  • 13,822
  • 6
  • 66
  • 112
  • The self hosted build agent isnt actually that hard to do, provided your network policy and sysadmins arent bureaucratically crippling/crippled when it comes to provisioning a new machine. You can also run the [agent as a container](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops), and I think you can actually d/l and modify the [images MSFT uses](https://hub.docker.com/_/microsoft-azure-pipelines-vsts-agent). – StingyJack Sep 22 '19 at 16:31
  • @StingyJack I've ran it before on a VM (before there was an official container image), and it was simple enough, but I still don't want the cost of running it, or the burden of securing and maintaining it. Also, I've a sneaky suspicion that trying to get my scenarion working with the agent hosted in a container (rather than a VM) would be fraught with frustration :) – Cocowalla Sep 22 '19 at 18:56
  • 1
    I've done probably > 100 build agents if counting all the tfs on premise versions since 2008. Its gotten way easier, but I understand your point. FWIW, I can only get a linux agent to build a linux image using the hosted agents. I cannot get either agent to run a container of either type. I have a support case open for that and its getting no traction in any direction. If I get something relevant I'll post it here – StingyJack Sep 22 '19 at 21:39
  • @StingyJack I doubt it will ever be possible to build a Windows image from Linux, but it is possible to build a Linux image from Windows (by switching to Linux container mode) - it's just not supported by the hosted build agents for some reason – Cocowalla Sep 23 '19 at 11:12

1 Answers1

4

Run Linux containers in an Azure DevOps Windows hosted build agent

Firstly, see the images listed which installed on Windows hosted agent: Docker images in Windows hosted agent. Docker EE on Server does not support Linux containers at all. So, it is impossible to build Linux docker image on Hosted Win-1803 agent. It can only build Windows docker image.

Until now, the only two workarounds is using self-hosted agent which based on Windows machine, or run a build which has two separate agent jobs(Pass the build artifacts back and forth between one agent job which run on Hosted Linux agent and the other is running on Hosted Windows agent) .

But since these two workarounds are all not convenient for you, there will not any other work around can achieve what you want.

In addition, there has a such suggestion feature raised on our official forum: Support for Docker with Linux Containers on Windows (LCOW) on hosted agent pool . You could vote and comment there, our Product Group team will review these suggestions regularly and consider taking it as Developer Roadmap. If this feature can be true, I think it will be very convenient to build Linux Container and without considering about which agent can only support.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • Isn't the list of images just the ones that are cached on the build agent, so you don't need to pull them? Also, I thought it was Docker Desktop that was on the build agents; do you have a source that it's Docker EE, and that it can't run Linux containers on Window? ([this](https://www.altaro.com/msp-dojo/linux-containers-windows-server-2019/) seems to disagree) – Cocowalla Sep 02 '19 at 14:01
  • FWIW, I upvoted the feature you linked to (but I never have a good experience with suggestions...). Like the person in the feature link, separate agent jobs won't help me here, since the purpose is running integration tests from Windows – Cocowalla Sep 02 '19 at 14:03
  • @Cocowalla, firstly, apologize about my not precise statement on " Docker EE on Server does not support Linux containers at all". The background of this statement is for Hosted agent we provided. As the link you shared, you can see that it is for **locally**, and also this is the workground we offered: using self-agent which based on **Windows machine**. But until now, we haven't expand this feature on our Hosted agent image. – Mengdi Liang Sep 02 '19 at 14:25
  • @Cocowalla, emhh, I seem understand something which not too good from**"never have a good experience with suggestions"**. As you see in our official suggestion forum, there has lots of suggestions there. Our Product group need to take the suggestion which has higher priority into the Roadmap. But this is not stable. Our group also consider the suggestion which is very urgent. As my colleague said, the workground is a bit kludgy. But until now, we have the higher priority sprint to released. – Mengdi Liang Sep 02 '19 at 14:33
  • @MerlinLiang-MSFT - Is there any difference between running an existing container (say to spin up a redis instance to facilitate some integration testing) and building an image on Docker EE? – StingyJack Sep 22 '19 at 16:35