1

I am trying to map a volume for C:\ProgramData. Unfortunately, Docker only gives a very generic message:

Error response from daemon: invalid volume specification: 'C:\ProgramData\Microsoft\VisualStudio:C:\ProgramData\Microsoft\VisualStudio:ro

Option:

-v "C:\ProgramData\Microsoft\VisualStudio":"C:\ProgramData\Microsoft\VisualStudio":ro

It worked before, then I made some modifications to the Dockerfile, and it doesn't any more. Does anyone have any idea?

Details

The mapping actually works on my local machine, but not in Azure DevOps, where I am using the created image for compiling some code.

The previous set of options, where it worked, was -v ... -v ... --mount src=..,dst=..,,type=bind,readonly. But I needed to change --mount to -v, because it had to be a volume.

The directory exists on the Azure agent, I checked.

For the critics - this is the way to reduce the image size. Create a volume e.g. under C:\Program Files, install a program (during the build phase) - and it's not taking any space in the actual image. But as all registry entries are correct, map the same directory on the agent - and the program is as good as installed inside the image. Except for this stopped working...

1 Answer 1

2

Okay, I don't know how that is tied together. But I added a dummy --mount option - and it worked.

The resulting command "outsources" Visual Studio and Windows SDK to the ADO agent:

docker run
    -v "C:\Program Files\Microsoft Visual Studio":"C:\Program Files\Microsoft Visual Studio":ro
    -v "C:\Program Files (x86)\Microsoft":"C:\Program Files (x86)\Microsoft":ro
    -v "C:\Program Files (x86)\Microsoft Visual Studio":"C:\Program Files (x86)\Microsoft Visual Studio":ro
    -v "C:\Program Files (x86)\Microsoft SDKs":"C:\Program Files (x86)\Microsoft SDKs":ro
    -v "C:\Program Files (x86)\Windows Kits":"C:\Program Files (x86)\Windows Kits":ro
    -v "C:\ProgramData\Microsoft\VisualStudio":"C:\ProgramData\Microsoft\VisualStudio":ro
    -v "C:\ProgramData\Microsoft\Windows":"C:\ProgramData\Microsoft\Windows":ro
    -v "C:\ProgramData\Package Cache":"C:\ProgramData\Package Cache":ro
    -v "C:\ProgramData\Microsoft\VisualStudio":"C:\ProgramData\Microsoft\VisualStudio":ro
    -v "C:\ProgramData\Microsoft\Windows":"C:\ProgramData\Microsoft\Windows":ro
    -v "C:\ProgramData\Package Cache":"C:\ProgramData\Package Cache":ro
    --mount src="C:\Program Files\Git\bin",dst="C:\dummy",type=bind,readonly
    xxx.azurecr.io/yyy:zzz
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Mike, according to the document, the --mount flag allows you to mount volumes, host-directories, and tmpfs mounts in a container. The --mount flag supports most options supported by the -v or the --volume flag, but uses a different syntax. Even though there is no plan to deprecate --volume, usage of --mount is recommended. Thanks for sharing the answer!
I had some trouble replacing -v with --mount. I can't remember the details now, but possibly due to the spaces and quotes.
Hi @Mike, thanks for your update. You can share the worked command in the answer. Happy coding! :)
And I recalled the trouble now - -v uses VOLUME definition in Dockerfile, --mount shouldn't have a corresponding volume.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.