This is the docker command I ran on windows container
docker run `
--name test `
--rm `
--interactive `
--entrypoint powershell.exe `
--network "Default Switch" `
mcr.microsoft.com/powershell:latest `
ls
I am expecting it will list all the files and exit with no errors and container got removed automatically.
but the result is
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d-r--- 4/11/2024 5:42 AM Program Files
d----- 4/5/2024 10:06 PM Program Files (x86)
d-r--- 4/5/2024 10:34 PM Users
d----- 4/11/2024 5:42 AM Windows
-a---- 6/9/2023 12:46 AM 5647 License.txt
time="2024-11-16T12:44:43+13:00" level=error msg="error waiting for container: unexpected EOF"
and the container log is:
request returned Internal Server Error for API route and version http://%2F%2F.%2Fpipe%2FdockerDesktopWindowsEngine/v1.47/containers/ede59be57ebfe3196f420ceac85f013f279c5161386b796f7171cf17121d50a0/json, check if the server supports the requested API version
and the container is not removed and I have to restart docker to remove the container.
if I remove --network "Default Switch"
then it works all good as what I expected, as docker put it in nat
network for windows containers.
I am just wondering why is this happening? if I want to use “Default switch”, how do I solve this problem?