mounting a directory on a 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. (

    I'm trying to mount a directory inside a image but it fails if I create another user.

    I use the following Dockerfile:

    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 image, everything works fine as well as with the 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