Skip to content

Instantly share code, notes, and snippets.

@atoa
Created September 26, 2016 18:40
Show Gist options
  • Save atoa/be0a816eba19ad7550928d9665ce3c56 to your computer and use it in GitHub Desktop.
Save atoa/be0a816eba19ad7550928d9665ce3c56 to your computer and use it in GitHub Desktop.
mount drive on docker for windows
$drive = $env:homedrive.Substring(0,1)
$ip = Get-NetIPConfiguration -InterfaceAlias "vEthernet (DockerNAT)" | Select IPv4Address
$unc = "//" + $ip.IPv4Address.IPAddress + "/" + $drive
[Environment]::SetEnvironmentVariable("UNC", $unc, "Process")
[Environment]::SetEnvironmentVariable("DRIVE", $drive, "Process")
docker run -ti --rm --privileged --pid=host -e USERNAME -e USERDOMAIN -e DRIVE -e UNC ubuntu nsenter --target 1 --mount --uts --ipc --net --pid sh -x -c '
[ -d "/${DRIVE}" ] || mkdir "/${DRIVE}" && \
mount.cifs "${UNC}" "/${DRIVE}" \
-o "user=${USERNAME},domain=${USERDOMAIN},noperm,forceuid,mfsymlinks,file_mode=0700,dir_mode=0700,nobrl,vers=3.0"
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment