Azure-pipelines-tasks: Incorrect volume mount when using Docker task to run image

Created on 4 Apr 2018  路  7Comments  路  Source: microsoft/azure-pipelines-tasks

Trying to use the Docker task from a yaml build file to generate protocol buffer documentation using https://github.com/pseudomuto/protoc-gen-doc. This docker image depends on mounting two volumes:

  • /protos is where it expects to find input files (protocol buffer definitions, .proto files)
  • /out is where it saves the generated documentation

    The task is defined like this in a .vsts-ci.yml file:

- task: Docker@0
  displayName: Generate protocol buffer documentation
  inputs:
    containerregistrytype: 'Container Registry'
    action: 'Run an image'
    imageName: 'pseudomuto/protoc-gen-doc'
    qualifyImageName: false
    volumes: |
      $(Build.ArtifactStagingDirectory):/out
      $(Build.SourcesDirectory):/protos
    detached: false

The repository contains only this yaml file (.vsts-ci.yml) and proto files. Unfortunately the protoc-gen-doc tool does not find any *.proto files when it starts so the build fails:

2018-04-04T08:18:45.7821024Z ##[section]Starting: Generate protocol buffer documentation
2018-04-04T08:18:45.7880850Z ==============================================================================
2018-04-04T08:18:45.7894865Z Task : Docker
2018-04-04T08:18:45.7908647Z Description : Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
2018-04-04T08:18:45.7922672Z Version : 0.3.11
2018-04-04T08:18:45.7936501Z Author : Microsoft Corporation
2018-04-04T08:18:45.7950138Z Help : More Information
2018-04-04T08:18:45.7964162Z ==============================================================================
2018-04-04T08:18:46.1756568Z [command]/usr/local/bin/docker run --rm -v /vsts/agent/_work/7/a:/out -v /vsts/agent/_work/7/s:/protos pseudomuto/protoc-gen-doc
2018-04-04T08:18:46.8460791Z protos/.proto: No such file or directory
2018-04-04T08:18:47.4043862Z ##[error]protos/
.proto: No such file or directory
2018-04-04T08:18:47.4096320Z ##[error]/usr/local/bin/docker failed with return code: 1
2018-04-04T08:18:47.4635057Z ##[section]Finishing: Generate protocol buffer documentation

To verify that files actually exist there I added a simple script step:

- script: |
        echo List files at Build.SourcesDirectory
        ls $(Build.SourcesDirectory)
  displayName: List files at Build.SourcesDirectory

Here is the output from this step:

2018-04-04T08:18:41.0250821Z ##[section]Starting: List files at Build.SourcesDirectory
2018-04-04T08:18:41.0323154Z ==============================================================================
2018-04-04T08:18:41.0336899Z Task : Command Line
2018-04-04T08:18:41.0350924Z Description : This is an early preview. Run a command line script using cmd.exe on Windows and bash on macOS and Linux.
2018-04-04T08:18:41.0366911Z Version : 2.127.0
2018-04-04T08:18:41.0380663Z Author : Microsoft Corporation
2018-04-04T08:18:41.0394989Z Help : More Information
2018-04-04T08:18:41.0409585Z ==============================================================================
2018-04-04T08:18:41.2763793Z Generating script.
2018-04-04T08:18:41.2923596Z [command]/bin/bash --noprofile --norc /vsts/agent/_work/_temp/e38e07c4-beef-4b65-85b8-05c91eef7fd4.sh
2018-04-04T08:18:41.2938301Z List files at Build.SourcesDirectory
2018-04-04T08:18:41.2952834Z my-client.proto
2018-04-04T08:18:41.2967982Z my-api.proto
2018-04-04T08:18:41.3017244Z ##[section]Finishing: List files at Build.SourcesDirectory

So the files do exist at $(Build.SourcesDirectory). Why don't they show up in the Docker container?

Release

All 7 comments

Bump! This seems to be a supported feature for Linux however it does not function.

Hi, Can you try to execute docker command "/usr/local/bin/docker run --rm -v /vsts/agent/_work/7/a:/out -v /vsts/agent/_work/7/s:/protos pseudomuto/protoc-gen-doc" manaually on your agent machine and check it is working or not. I tried on my setup i didn't any issues.

Hi, is this issue resolved? which agent are you using? i have tried same scenario with "Hosted Linux Preview" agent. I am not able to repro the issue. It is working fine and generting index.html file in $(Build.ArtifactStagingDirectory) directory.

Please open the issue if are still facing the issue.

For information: this seems to have been a problem / limitation in our build agent that is running in AKS with the https://hub.docker.com/r/microsoft/vsts-agent/ image. It works when running with the Microsoft hosted Ubuntu image.

For information: this seems to have been a problem / limitation in our build agent that is running in AKS with the https://hub.docker.com/r/microsoft/vsts-agent/ image. It works when running with the Microsoft hosted Ubuntu image.

@ahaeber did you solve this issue? I'm struggling with the same problem

@Shaked I never tested this on our on-premise agents again. At least it works on the hosted agents.

Was this page helpful?
0 / 5 - 0 ratings