Hi Team,
I am trying to bind an FSX share to a windows pods. I created a test app with windows image. i am using net use command(tried with New-Psdrive command as well) to connect to the share once the container is created. When I check the logs of the pods I am seeing “System error 53 has occurred.
The network path was not found.” error. However if i exec inside the container and run the same net use command, i am able to successfully map the drive.
What could be the issue? Or is this the right way to mount a FSX share to the pod? i have set persistent to be true to make sure that share is available if i exit out of the pod, however when i exec again the drive is gone and i need to run the command again to map it.
Here is DockerFile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
WORKDIR /fortify
COPY . ./
ENTRYPOINT ["powershell",".\\test.ps1"]
Here is my test.ps1 content:
# This is a super **SIMPLE** example of how to create a very basic powershell webserver
# 2019-05-18 UPDATE — Created by me and and evalued by @jakobii and the comunity.
#Add the Ps Drive
#$secpasswd = ConvertTo-SecureString “password” -AsPlainText -Force
#$mycreds = New-Object System.Management.Automation.PSCredential (“dev.test.global\svc-FSX_dockerspt”, $secpasswd)
#New-PSDrive –Name “P” –PSProvider FileSystem –Root “\\amznfs.dev.test.global\share” –Persist -Credential $mycreds | out-null
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
# Start the Http Server
$http.Start()
Add-Type -AssemblyName System.Web
# Log ready message to terminal
if ($http.IsListening) {
write-host "HTTP Server Ready! " -f 'black' -b 'gre'
write-host "$($http.Prefixes)" -f 'y'
}
(net use Z: \\amznfs.dev.test.global\share password /user:dev.test.global\svc-FSX_dockerspt /persistent:yes) | Out-Null
Get-Psdrive
# INFINTE LOOP
# Used to listen for requests
while ($http.IsListening) {
# Get Request Url
# When a request is made in a web browser the GetContext() method will return a request object
# Our route examples below will use the request object properties to decide how to respond
$context = $http.GetContext()
if ($context.Request.HttpMethod -eq 'GET') {
# We can log the request to the terminal
write-host "$($context.Request.UserHostAddress) => $($context.Request.Url)" -f 'mag'
$URL = $context.Request.Url.LocalPath
# Redirect root to index.html
if($URL -eq "/") {
$URL = "/index.html"
}
$ContentStream = [System.IO.File]::OpenRead( "web/$URL" );
$Context.Response.ContentType = [System.Web.MimeMapping]::GetMimeMapping("web/$URL")
$ContentStream.CopyTo( $Context.Response.OutputStream );
$Context.Response.Close()
}
# powershell will continue looping and listen for new requests...
}