none
mounting a directory on a mcr.microsoft.com/windows:1809 container fails if not the default user is used RRS feed

  • General discussion

  • I guess this is a bug. I already posted my question on stackoverflow but I got no reply. (https://stackoverflow.com/questions/58353337/mounting-a-directory-on-a-mcr-microsoft-com-windows1809-container-fails-if-not)

    I'm trying to mount a directory inside a mcr.microsoft.com/windows:1809 image but it fails if I create another user.

    I use the following Dockerfile:

    FROM mcr.microsoft.com/windows:1809
    RUN NET USER mynewuser /add
    RUN NET LOCALGROUP Administrators /add mynewuser
    USER mynewuser

    After building the container I run it with docker run -it --rm -v ${PWD}:C:\data containername. But when I try to cd into the data folder I get the following error:

    C:\>cd data
    Access is denied.
    When I use the powershell inside the container I can cd into the data folder but a dir command fails:
    PS C:\> cd data
    PS C:\data> dir
    dir : Access to the path 'C:\data' is denied.
    At line:1 char:1
    + dir
    + ~~~
        + CategoryInfo          : PermissionDenied: (C:\data:String) [Get-ChildItem], UnauthorizedAccessException
        + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

    When using the mcr.microsoft.com/windows/servercore:1809 image, everything works fine as well as with the mcr.microsoft.com/windows:1809 container.

    Do I need to set permissions for the user even though the new user should already have administrator rights or is it a bug of the image?

    Tuesday, October 22, 2019 6:03 AM