dockerazure-devopsdocker-for-windows

Mapping ProgramData in Docker Windows


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...


Solution

  • 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