2

I want to mount a file share in a windows container. I have tried to mount an Azure File storage share, and intially it works fine. I can browse the files in the directory.

However, when I disconnect and reconnect my container powershell-session, the share is marked 'Unavailable'. Also, the share is not available to the executable running as my ENTRYPOINT.

    docker exec -it a4 powershell
    **************
    PS C:\> net use z: \\XXXX.file.core.windows.net\dockerstore /u:XXXXX XXXXXX== /P:Yes
    The command completed successfully.

    PS C:\> net use
    New connections will be remembered.


    Status       Local     Remote                    Network

    -------------------------------------------------------------------------------
    OK           Z:        \\XXXX.file.core.windows.net\dockerstore
                                                    Microsoft Windows Network
    The command completed successfully.


    exit

    ******************
    docker exec -it a4 powershell
    **********************
    PS C:\> net use
    New connections will be remembered.


    Status       Local     Remote                    Network

    -------------------------------------------------------------------------------
    Unavailable  Z:        \\XXXX.file.core.windows.net\dockerstore
                                                    Microsoft Windows Network
    The command completed successfully.

I also tried mounting the network drive on the host, and mounting it in the container. But docker-compose fails to bring it up (access-problem?):

Cannot create container for service configserver-c: invalid bind mount spec "z:\\Certificates:c:\\Certificates:rw": invalid volume specification: 'z:\Certificates:c:\Certificates:rw': invalid mount config for type "bind": bind source path does not exist

Are there other options to persistently mount an external file share? (I don't know of any Docker Volume drivers available for windows.)

Some more information: I use Docker for Windows on Windows 10 with Hyper-V isolation.

Docker version:

    Client:
     Version:      17.03.1-ce
     API version:  1.27
     Go version:   go1.7.5
     Git commit:   c6d412e
     Built:        Tue Mar 28 00:40:02 2017
     OS/Arch:      windows/amd64

    Server:
     Version:      17.03.1-ce
     API version:  1.27 (minimum version 1.24)
     Go version:   go1.7.5
     Git commit:   c6d412e
     Built:        Tue Mar 28 00:40:02 2017
     OS/Arch:      windows/amd64
     Experimental: true
miguelmorin
  • 5,025
  • 4
  • 29
  • 64
  • 1
    Shares exist only in user session which you created, other users or other session will not see it. It works the same way on you desktop. Try to use $session object instead `PS C:\> $session = New-PSSession -ContainerId (get-Container ed).ID -RunAsAdministrator PS C:\> Invoke-Command -Session $session -Command {$env:mytest = "test"} PS C:\> Invoke-Command -Session $session -Command {Write-Output $env:mytest} test` – Gregory Suvalian Jun 08 '17 at 12:09
  • 1
    @GSA Thanks for your input. Think I will try to use CMDKEY to add credentials to the user, and use UNC paths instead. Will post the result. – Andreas Ludviksen Jun 09 '17 at 11:26
  • What is your business with containers and necessity to have users login to container on console? – Gregory Suvalian Jun 09 '17 at 12:26
  • I have multiple services as containers. Both Windows-services and web-services. Some of these need access to files on an Azure Files storage. In the question above, I tried to put it simple. I do not need to do this using a console-session, it could be done in a script or in a Dockerfile. The main thing is that the user under which the service runs have access to the external storage. – Andreas Ludviksen Jun 09 '17 at 16:18
  • @AndreasLudviksen Trying to do the exact same thing, did you get it working? – eselk Jun 15 '17 at 15:21
  • 1
    @eselk Yes. I was able to make the volume permanently available by using 'cmdkey' in the Dockerfile, and UNC paths in the application. Also, if I run the application under a user with the same username/password as the Azure File Storage, the application can access the storage. See this post for more information: https://stackoverflow.com/questions/44488399/windows-container-fails-to-reach-azure-file-storage – Andreas Ludviksen Jun 16 '17 at 21:08

1 Answers1

0

Another solution is to mount volume when you build your images in the docker file.

Ehsan
  • 141
  • 1
  • 8