简体   繁体   中英

Azure DevOps YAML build fail when running container jobs on self hosted agent

I'm trying to run a container job on my self hosted agent to read a container image from my ACR.

When you use a Microsoft hosted agent this code works:

pool:
  vmImage: 'ubuntu-18.04'
container:
  image: myprivate.azurecr.io/windowsservercore:1803
  endpoint: my_acr_connection

So what I want is to use the following code:

pool: Default
container:
  image: myprivate.azurecr.io/windowsservercore:1803
  endpoint: my_acr_connection

But I get this error in the "Initialize job" step when I run the pipeline:

##[error]File not found: 'docker'

I only have one agent in Default agent pools. My agent was created following this documentation: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops#linux

I guess this is something related to the agent capabilities, but I wanted to know if what I'm trying is actually feasible and if so if you could provide me some advice on how to resolve my issue.

Thank you in advance.

EDIT:

I was able to handle this error. I just needed to install docker inside the container, within the Dockerfile.

Now I receive another error, in the "Initialize containers" pipeline's step:

Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/__a/externals/node/bin/node": stat /__a/externals/node/bin/node: no such file or directory: unknown

Issue here was the default pool might not have docker installed in it, once the default pool had docker installed then the error is gone.

I am stuck with the OCI Runtime error too "Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/__a/externals/node/bin/node": stat /__a/externals/node/bin/node: no such file or directory: unknown"

So I had the very same problem of:

"Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/__a/externals/node/bin/node": stat /__a/externals/node/bin/node: no such file or directory: unknown"

In my case, I was using a self hosted agent running on a WSL1 ubuntu on Windows 10 with Docker4Windows in WSL2. The problem is that WSL1 with docker has a problem with the volumes mounted as directories, that have to be defined with the windows path (/c/users....) instead of the local linux path (/home/user/linuxuser/...).

The problem was resolved after moving my agent to a WSL2, where the mounting problem does not happen.

Regardless of the WSL issue, the problem is that the volume /__a/externals cannot be mounted on the container in the agent node. One thing to test is to check in azure devops pipeline for the failed step logs and check the docker commands that failed. You will see something like this:

/usr/bin/docker create --name .... -v "/home/user/agent_directory/externals":"/__a/externals":ro ... CONTAINER_IMAGE

docker start b39b96fb ....

Error response from daemon: OCI runtime create failed ...

So you can check to launch your image manually mounting the volumes to see if they are correctly mounted, to detect the problem with docker (can be permission issues or other docker linux related problems).

docker run --rm -ti -v "/home/user/agent_directory/externals":"/__a/externals":ro mcr.microsoft.com/dotnet/core/sdk:3.1 bash

(In my case the image was dotnet/core but the problem may occur with any image).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM