How can you mount a volume before running a job in here? That would be a very useful feature.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Could you use the options property on the container to set up the mount like you would on a normal docker container run invocation?
It also does support mounting directly here: https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=example#resources
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
Vote for parsing variables within resources here:
https://developercommunity.visualstudio.com/idea/816606/allow-variables-at-resourcesrepositoriesrepository.html
and here:
https://developercommunity.visualstudio.com/idea/889521/support-yaml-variable-expansion-in-container-resou.html
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.
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: