moby: New-SmbGlobalMapping don't continued working in Container
I have report same New-SmbGlobalMapping problem in here. Sorry, I don’t know where is right area.
https://github.com/docker/for-win/issues/2606
Steps to reproduce the issue: Host 1: File Server
Server Core 1803
New-SmbShare -Name DocFiles -Path "D:\DocFiles\" -FullAccess Everyone
Host 2: docker Host
$creds = Get-Credential
New-SmbGlobalMapping -RemotePath \\Host1\\DocFiles -Credential $creds -LocalPath Z:
- Run Swarm Service
docker service create `
--name docfiles `
--replicas=1 `
--constraint 'node.labels.osname == Host2' `
--mount "type=bind,source=Z:\images,destination=C:\inetpub\wwwroot\images" `
--publish published=8080,target=80,protocol=tcp `
microsoft/iis:windowsservercore-1803
- Run docker-compose
version: '3'
services:
docfiles:
container_name: docfiles
image: microsoft/iis:windowsservercore-1803
ports:
- "7003:80"
volumes:
- Z:\images\:C:\inetpub\wwwroot\images\
- Run
docker run
docker run -d -p 7003:80 -v Z:\images\:C:\inetpub\wwwroot\images\ microsoft/iis:windowsservercore-1803
Describe the results you received:
Now, I can access Host 2 images folder data from IIS service. but wait a minute, will get HTTP 500. ( swarm, compose, docker run same result)
Run docker exec into container, run dir C:\inetpub\wwwroot\ or dir C:\inetpub\wwwroot\images will get access deny message.
PS C:\inetpub\wwwroot> dir
dir : Access to the path 'C:\inetpub\wwwroot' is denied.
At line:1 char:1
+ dir
+ ~~~
+ CategoryInfo : PermissionDenied: (C:\inetpub\wwwroot:String) [Get-ChildItem], UnauthorizedAccessException
+ FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Describe the results you expected:
Mount New-SmbGlobalMapping
command disk (or folder) to container volume and continued working.
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker version
:
Client:
Version: 18.03.1-ee-2
API version: 1.37
Go version: go1.10.2
Git commit: ebbcd7e
Built: Tue Jul 10 21:32:32 2018
OS/Arch: windows/amd64
Experimental: false
Server:
Engine:
Version: 18.03.1-ee-2
API version: 1.37 (minimum version 1.24)
Go version: go1.10.2
Git commit: ebbcd7e
Built: Tue Jul 10 21:49:06 2018
OS/Arch: windows/amd64
Experimental: true
Output of docker info
:
Containers: 11
Running: 9
Paused: 0
Stopped: 2
Images: 35
Server Version: 18.03.1-ee-2
Storage Driver: windowsfilter (windows) lcow (linux)
Windows:
LCOW:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: active
NodeID: katfcy8mm46drlotguaen45x3
Is Manager: true
ClusterID: mkzqq3nudssg6hlu9wkfc8bz8
Managers: 3
Nodes: 3
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: x.x.x.223
Manager Addresses:
x.x.x.223:2377
x.x.x.224:2377
x.x.x.225:2377
Default Isolation: process
Kernel Version: 10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)
Operating System: Windows Server Datacenter Version 1803 (OS Build 17134.112)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 16GiB
Name: host2
ID: QBMU:FFGX:6VJK:XX4C:KLJX:A753:TRIS:THT3:OZAX:XAE2:HQ2Q:KF4M
Docker Root Dir: D:\docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.):
Docker Host is VM, Running Windows Server Core 1803
PS C:\WINDOWS\system32> systeminfo
Host Name: Host2
OS Name: Microsoft Windows Server Standard
OS Version: 10.0.17134 N/A Build 17134
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Server
OS Build Type: Multiprocessor Free
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 17 (1 by maintainers)
Hi, Just use the -RequirePrivacy $true along with the New-SMBGlobalMapping.
MUP cache seems to be a problem here. The MUP cache clears every 15 minutes and the credentials to the SMB File Share are not saved.
New commands looks like - New-SMBGlobalMapping -RemotePath \contosofileserver\share1 -LocalPath G: -RequirePrivacy $true
I was able to resolve this on Windows Server 2019 with these steps:
I’ve experienced the same issue when I was testing IIS containers with application which requires access to the resources on SMB shares (Azure File Share). For now, the workaround could be running the containers with hyper-v isolation mode where the bind mount to the mapped drive seems to be working without any issues.
The
process
andhyperv
isolation modes accessing a docker daemon host file system using different logic: read more what could suggest that onprocess
mode something on docker host is recognizing the container process as not permitted for accessing the share drive and blocks this access. The Windows Defender is disabled and no other security tool is running on VM so this looks really strange.Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Docker Host is Azure VM, Running Windows Server 2019 Datacenter Version 1809 (OS Build 17763.437)
I’m following these advises but still confused. Tried using both
New-SmbGlobalMapping -RemotePath "\\10.0.0.4\data" -Credential $credentialObject -LocalPath Z: -FullAccess @( "NT AUTHORITY\SYSTEM", "NT AUTHORITY\NetworkService" ) -Persistent $true -RequirePrivacy $true
and
New-SmbGlobalMapping -RemotePath "\\10.0.0.4\share" -Credential $credentialObject -LocalPath Z: -RequirePrivacy $true
Then
docker run -d --name webserver -v Z:\content\:C:\inetpub\wwwroot -p 80:80 microsoft/iis
But getting access denied if trying to go to that folder in the container (or 500 in the webserver). Accessing Z: in windows or writing files to it is no problem at all. 10.0.0.4, in this case, is a SAMBA server from an ubuntu machine. And mounting any local drive like D: works fine too.
EDIT: Ok, so this works for me as a workaround. I’m mounting the SMB drive INSIDE the container instead. I’m not sure what the drawbacks would be but it seems to work.
@jjohnson-33 I tried your solution of using a SymLink but I got the same behavior which is that it works for about 12 minutes in my case and then something must change or timeout and I start getting Access denied.
Were there any other steps at all you might have took to get this working?
This is on Windows Server 2019 with DockerEE 19.03.2.
I ran into the similar problem. There were two kinds of result,
The parameter is incorrect.
andAccess is denied.
. I think this is a network-timeout related issue.As long as I tested,
Something similar happens in my environment. A single container, after a running time, displays Access Denied.
In my case the service has a healtcheck enabled, then the container returns to air quickly.
but is normal users complain that they fell from the system because of this situation