Azure-devops-docs: Mount volume

Created on 19 Jul 2019  Â·  9Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

How can you mount a volume before running a job in here? That would be a very useful feature.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cictech devopprod doc-bug

Most helpful comment

Docker wants absolute paths on the left-hand side of a volume mount. But Container resources are parsed before pipeline variables are available. These volumes and environment parameters get passed as-is when the agent actually starts the container. On an azure pipelines agent hosted and supported by Microsoft, an absolute path is not a good idea. Wish this worked:

container:
  image: my-image:latest
  endpoint: my-acr-endpoint
  env:
    RELEASE_MAJOR: $(Date:yyyyMMdd)
    RELEASE_MINOR: $(Rev:r)
  volumes:
    - $(Build.SourcesDirectory):/srv/src:ro
    - $(Build.ArtifactStagingDirectory):/srv/build:rw
  options:
    --workdir /srv/src

All 9 comments

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=example#container-reference

Could you use the options property on the container to set up the mount like you would on a normal docker container run invocation?

Is there documentation about how to mount azure files volume? I have always mounted using things like azure cli or powershell, not with options in a docker command.

We don't document anything other than native Docker mounts, which are mentioned here. The volumes syntax matches Docker Compose format.

Docker wants absolute paths on the left-hand side of a volume mount. But Container resources are parsed before pipeline variables are available. These volumes and environment parameters get passed as-is when the agent actually starts the container. On an azure pipelines agent hosted and supported by Microsoft, an absolute path is not a good idea. Wish this worked:

container:
  image: my-image:latest
  endpoint: my-acr-endpoint
  env:
    RELEASE_MAJOR: $(Date:yyyyMMdd)
    RELEASE_MINOR: $(Rev:r)
  volumes:
    - $(Build.SourcesDirectory):/srv/src:ro
    - $(Build.ArtifactStagingDirectory):/srv/build:rw
  options:
    --workdir /srv/src

Thanks for the feature requests. No promises but they seem like something we ought to do.

How can I mount $(Build.SourcesDirectory) when container resources are parsed before pipelines variables are available? I would have to pass in the absolute path of the source directory, but is that even a known and unchanging value when running a container job on a microsoft hosted build agent?

This is a crippling limitation for my use case. I use containers extensively for holding my toolchains, but if I cannot mount my source code folder, then that use case isn't really supported.

I just realized that $(Build.SourcesDirectory) is automatically mounted and used as the workdir for container jobs.

I still think that it would be a very nice feature to be able to use variables when doing volume mounts.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adnanebrahimi picture adnanebrahimi  Â·  3Comments

Naphier picture Naphier  Â·  3Comments

sevaa picture sevaa  Â·  3Comments

dannyvv picture dannyvv  Â·  3Comments

o-o00o-o picture o-o00o-o  Â·  3Comments