Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Linux containers in an Azure DevOps Windows hosted build agent

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?

like image 249
Cocowalla Avatar asked Oct 15 '22 11:10

Cocowalla


1 Answers

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.

like image 67
Mengdi Liang Avatar answered Oct 21 '22 09:10

Mengdi Liang