3
votes

I tried to run a docker command through the docker task in Azure devops with the build in docker task. As variable for the volume of the docker command I gave this as value enter image description here

But it keeps failing with the error

/usr/bin/docker: Error response from daemon: create $(pwd)/out: "$(pwd)/out" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.

I tried to give the same docker run command with the same -v value inside my local machine and this works perfectly. So I guess this is an Azure devops problem or a value that I forget to give along

My host agent is an ubuntu16 And the build task is as followed enter image description here enter image description here

1

1 Answers

6
votes

You're trying to reference a variable named pwd. There is no such predefined variable in Azure Pipelines.

You mention that this works in your local machine, but that's not because there's a pwd variable defined. (In fact, there's probably not a pwd environment variable in your environment.) That's because $(pwd) is POSIX command substitution. It's actually executing the pwd command.

This POSIX shell syntax will not work in Azure Pipelines configuration.

Instead, use one of the Azure Pipelines variables.

For example, if you want to map the sources directory, you can set the volumes field to:

$(Build.SourcesDirectory):/src

Or map source and binaries:

 $(Build.SourcesDirectory):/src
 $(Build.BinariesDirectory):/build