buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Buildkit on Windows Server 2019 Unable to Reuse Namespaces / Endpoints

Open nerddtvg opened this issue 1 year ago • 16 comments

When running on Server 2019, buildkit is unable to reuse a namespace for the second RUN command in a Dockerfile (or subsequent runs). The namespace state is 1 and endpoint state is 4 (Detatched).

An identical buildkit, containerd, cni configuration in Server 2022 works without issue.

Server 2019 1809
Microsoft Windows NT 10.0.17763.0

buildkitd --version
buildkitd github.com/moby/buildkit v0.18.2 e4da654b1251f91e914fab18eba33743aefd7080

containerd --version
containerd github.com/containerd/containerd/v2 v2.0.1 88aa2f531d6c2922003cc7929e51daf1c14caa0a

nerdctl --version
nerdctl version 2.0.2

I have tried the Windows CNI plugin versions 0.3.0 and 0.3.1.

This is a similar error to: https://github.com/moby/buildkit/issues/4960 However, the subnet and NAT configurations are correct and match the existing nat HnsNetwork.

Sample Dockerfile:

FROM mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2019

SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell", "-NonInteractive", "-NoProfile", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN ipconfig /all
RUN nslookup google.com
RUN ping google.com

ENTRYPOINT ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell", "-Command", "$sec = Get-Random -Minimum 10 -Maximum 100 ; Write-Host $sec ; Start-Sleep -Seconds $sec"]

buildkitd logs:

time="2025-01-16T15:36:59Z" level=debug msg="load cache for [1/4] FROM mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2019@sha256:feca15ab0fa7f47610aabfd72f9d87c9926b520b67c824003e9d44aaf2095424 with amcuh3zdpvou93q7u656cj3da::9y7eql5jiyjat2ld2ci8voerl"
time="2025-01-16T15:36:59Z" level=debug msg="Calling proc (1)"
time="2025-01-16T15:36:59Z" level=debug msg="Calling proc (2)"
time="2025-01-16T15:37:00Z" level=debug msg="creating new network namespace rrinwqxoq8xx5xyw2ehllg2dl" span="[2/4] RUN ipconfig /all" spanID=5b1a16f33e8cbd78 traceID=f9b970ce5f01f392bee8dca451ba00c4
time="2025-01-16T15:37:00Z" level=debug msg="hcn::HostComputeNamespace::Create id="
time="2025-01-16T15:37:00Z" level=debug msg="hcn::HostComputeNamespace::Create JSON: {\"Type\":\"Guest\",\"SchemaVersion\":{\"Major\":2,\"Minor\":0}}"

time="2025-01-16T15:37:00Z" level=debug msg="finished creating network namespace rrinwqxoq8xx5xyw2ehllg2dl" span="[2/4] RUN ipconfig /all" spanID=5b1a16f33e8cbd78 traceID=f9b970ce5f01f392bee8dca451ba00c4
time="2025-01-16T15:37:00Z" level=debug msg="finished setting up network namespace rrinwqxoq8xx5xyw2ehllg2dl" span="[2/4] RUN ipconfig /all" spanID=5b1a16f33e8cbd78 traceID=f9b970ce5f01f392bee8dca451ba00c4
time="2025-01-16T15:37:08Z" level=debug msg="Calling proc (1)"
time="2025-01-16T15:37:08Z" level=debug msg="Calling proc (2)"
time="2025-01-16T15:37:08Z" level=debug msg="returning network namespace rrinwqxoq8xx5xyw2ehllg2dl from pool" span="[3/4] RUN nslookup google.com" spanID=c7b93686715648d1 traceID=f9b970ce5f01f392bee8dca451ba00c4
time="2025-01-16T15:37:09Z" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = process \"C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com\" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem sl4e3pv92h6my5lu0k08bdg34: The requested operation for attach namespace failed.: unknown" spanID=abb02b324b4c34d9 traceID=f9b970ce5f01f392bee8dca451ba00c4
process "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem sl4e3pv92h6my5lu0k08bdg34: The requested operation for attach namespace failed.: unknown
4052 v0.18.2 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-worker=true --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --debug --log-file=C:\Windows\Temp\buildkitd.log
main.unaryInterceptor
        /src/cmd/buildkitd/main.go:717
google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1
        /src/vendor/google.golang.org/grpc/server.go:1202
github.com/moby/buildkit/api/services/control._Control_Solve_Handler
        /src/api/services/control/control_grpc.pb.go:289
google.golang.org/grpc.(*Server).processUnaryRPC
        /src/vendor/google.golang.org/grpc/server.go:1394
google.golang.org/grpc.(*Server).handleStream
        /src/vendor/google.golang.org/grpc/server.go:1805
google.golang.org/grpc.(*Server).serveStreams.func2.1
        /src/vendor/google.golang.org/grpc/server.go:1029
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1700

4052 v0.18.2 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-worker=true --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --debug --log-file=C:\Windows\Temp\buildkitd.log
github.com/moby/buildkit/solver/llbsolver/ops.(*ExecOp).Exec
        /src/solver/llbsolver/ops/exec.go:493
github.com/moby/buildkit/solver.(*sharedOp).Exec.func2
        /src/solver/jobs.go:1100
github.com/moby/buildkit/util/flightcontrol.(*call[...]).run
        /src/util/flightcontrol/flightcontrol.go:122
sync.(*Once).doSlow
        /usr/local/go/src/sync/once.go:76
sync.(*Once).Do
        /usr/local/go/src/sync/once.go:67
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1700

4052 v0.18.2 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-worker=true --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --debug --log-file=C:\Windows\Temp\buildkitd.log
github.com/moby/buildkit/solver.(*edge).execOp
        /src/solver/edge.go:966
github.com/moby/buildkit/solver/internal/pipe.NewWithFunction[...].func2
        /src/solver/internal/pipe/pipe.go:78
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1700

time="2025-01-16T15:37:09Z" level=debug msg="session finished: <nil>" spanID=64affebe8305aa53 traceID=f9b970ce5f01f392bee8dca451ba00c4

Windows Hyper-V-Compute event log:

[sl4e3pv92h6my5lu0k08bdg34] Create Container, type 'Silo Container', settings '{"Owner":"containerd-shim-runhcs-v1.exe","SchemaVersion":{"Major":2,"Minor":1},"Container":{"GuestOs":{"HostName":"buildkitsandbox"},"Storage":{"Layers":[{"Id":"1a3348c8-c43b-5c1a-83f4-4bbff0d32f39","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\98"},{"Id":"9caf22d5-d18a-59e5-afd8-a5e3870a1fee","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\90"},{"Id":"298e3ca2-da55-5141-8d6a-d1924c6353ed","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\89"},{"Id":"fb9d2f2a-b87c-5a9c-99c0-9e720042277a","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\88"},{"Id":"2137054d-9b8a-5e07-8472-e1f06abc13fa","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\87"},{"Id":"1d381a65-06c4-5a2a-8ba6-842762e847b5","Path":"C:\\ProgramData\\containerd\\root\\io.containerd.snapshotter.v1.windows\\snapshots\\86"}],"Path":"\\\\?\\Volume{ca559c84-13df-4d85-897c-57fec4a804e0}\\"},"MappedDirectories":[{"HostPath":"\\\\?\\Volume{12586166-25a9-4653-bc2f-258d609e6840}\\Program Files\\buildkit\\buildkitd.exe","ContainerPath":"C:\\Windows\\System32\\get-user-info.exe","ReadOnly":true}],"MappedPipes":[{"ContainerPipeName":"otel-grpc","HostPath":"\\\\.\\pipe\\buildkit-otel-grpc"}],"Processor":{},"Networking":{"Namespace":"8d8fd7ab-75aa-4945-8cf5-8dfb906a9cae"},"RegistryChanges":{"AddValues":[{"Key":{"Hive":"System","Name":"ControlSet001\\Control"},"Name":"WaitToKillServiceTimeout","Type":"String","StringValue":"2147483647"}]}},"ShouldTerminateOnLastHandleClosed":true}'

[sl4e3pv92h6my5lu0k08bdg34] Queue system notification: 2 / 0x803B002E

[sl4e3pv92h6my5lu0k08bdg34] Create compute system, result 0x803B002E

HCN_E_NAMESPACE_ATTACH_FAILED 	The requested operation for attach namespace failed 	0x803b002E

HNS Output:

PS > Get-HnsEndpoint

ActivityId                : 2974E63E-C9DD-4A5B-A867-65069FBFA448
AdditionalParams          :
CreateProcessingStartTime : 133815154201296258
DNSServerList             : 168.63.129.16
DNSSuffix                 : yzspoegj5jtuzenk3d2ra04d2g.bx.internal.cloudapp.net
EnableLowInterfaceMetric  : True
EncapOverhead             : 0
GatewayAddress            : 172.24.96.1
Health                    : @{LastErrorCode=0; LastUpdateTime=133815154201266283}
ID                        : CC4C7F16-26BC-4CDF-B052-E840FE09DA93
IPAddress                 : 172.24.105.2
InterfaceConstraint       : @{InterfaceGuid=00000000-0000-0000-0000-000000000000}
MacAddress                : 00-15-5D-41-7B-2F
Name                      : rrinwqxoq8xx5xyw2ehllg2dl_nat
Namespace                 : @{ID=8D8FD7AB-75AA-4945-8CF5-8DFB906A9CAE; IsDefault=False}
Policies                  : {}
PrefixLength              : 20
RemoveProcessingStartTime : 133815154255318204
Resources                 : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; Health=; ID=2974E63E-C9DD-4A5B-A867-65069FBFA448; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0; parentId=871E0337-F1D6-45D2-9BD3-71BEB6A40E21}
SharedContainers          : {}
StartTime                 : 133815154288301459
State                     : 4
Type                      : NAT
Version                   : 38654705669
VirtualNetwork            : 10de7571-39fa-4fa5-9c94-b06cee9dc9c1
VirtualNetworkName        : nat



PS > Get-HnsNamespace -Id 8D8FD7AB-75AA-4945-8CF5-8DFB906A9CAE

ActivityId       : 381977D2-D854-45C7-B386-961006DD4892
AdditionalParams :
CompartmentGuid  : 00000000-0000-0000-0000-000000000000
CompartmentId    : 2
Containers       : {}
Health           : @{LastErrorCode=0; LastUpdateTime=133815154200336902}
ID               : 8D8FD7AB-75AA-4945-8CF5-8DFB906A9CAE
IsDefault        : False
Policies         : {}
ResourceList     : {@{Data=; Type=Endpoint}}
Resources        : @{AdditionalParams=; AllocationOrder=0; Health=; ID=381977D2-D854-45C7-B386-961006DD4892; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0}
State            : 1
Type             : VM
Version          : 38654705669

If I remove the HnsEndpoint (Get-HnsEndpoint | Where-Object {$_.State -eq 4} | Remove-HnsEndpoint), the container will run one step and fail on the next RUN trying to re-use the endpoint. The container won't be able to connect out to the Internet though, ping and DNS lookups fail.

#7 [4/4] RUN ping google.com
#7 4.874 Ping request could not find host google.com. Please check the name and try again.
#7 ERROR: process "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ping google.com" did not complete successfully: exit code: 1
------
 > [4/4] RUN ping google.com:
4.874 Ping request could not find host google.com. Please check the name and try again.

Since the CNI pool size cannot be less than one (setting 0 provisions a single namespace) and the cache time cannot be adjusted (const 5 minutes), I can find no workaround to prevent the namespace reuse on 2019. If the namespace was cleaned up each time, this would work.

I'm unsure the root cause of the bug, if it is a 2019 HCS issue or not.

nerddtvg avatar Jan 16 '25 15:01 nerddtvg

I did test buildkit v0.19.0-rc2 to make sure it wasn't already fixed and the same error occurs.

nerddtvg avatar Jan 16 '25 16:01 nerddtvg

ACK, will take a look and get back.

profnandaa avatar Jan 17 '25 11:01 profnandaa

I am facing the same issue on Server 2019, first RUN instruction succeeds, the second one fails always with: The requested operation for attach namespace failed.: unknown

peterfocko avatar Jan 18 '25 01:01 peterfocko

HI @nerddtvg -- I have not been able to repro on WS2019, I've stumbled on some other unrelated errors trying to run buildctl (which you can ignore for now):

Can I get this from you please, I'd like to confirm something about the NetworkAdapter and the HnsNetwork:

Get-NetAdapter # list all of them, I'd like to see which one the HnsNetwork is connected to
$nat = Get-HnsNetwork | where {$_.Name -eq "nat" }

And also, what do you get when you run this ctr command?:

ctr run --rm --cni mcr.microsoft.com/windows/nanoserver:ltsc2019 cni-test curl -I example.com

I'm working to solve this CNI setup issue once and for all. Seems like we have a couple of setup scripts around that are not all coherent...

profnandaa avatar Jan 24 '25 13:01 profnandaa

@profnandaa Below are the requested responses.

PS C:\Windows\system32> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
vEthernet (nat)           Hyper-V Virtual Ethernet Adapter             18 Up           00-15-5D-4A-2A-41        10 Gbps
Ethernet0                 vmxnet3 Ethernet Adapter                      9 Up           00-50-56-90-70-07        10 Gbps


PS C:\Windows\system32> Get-HnsNetwork


ActivityId             : F6566D6A-7468-46CF-B33B-E0F824681E66
AdditionalParams       :
CurrentEndpointCount   : 0
Extensions             : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension}, @{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags                  : 0
Health                 : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=0; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=133819496200703357; RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0}
ID                     : F6C5EF13-C350-4695-B9C9-DE9B2A87FBF8
IPv6                   : False
InterfaceConstraint    : @{InterfaceGuid=00000000-0000-0000-0000-000000000000}
LayeredOn              : 2F75B87E-2BD0-463B-973B-14691C40C0DC
MacPools               : {@{EndMacAddress=00-15-5D-4A-2F-FF; StartMacAddress=00-15-5D-4A-20-00}}
MaxConcurrentEndpoints : 5
Name                   : nat
NatName                : ICS79A62C55-619B-4670-8714-9CBC8EDA9C54
NetworkAdapterName     : Ethernet0
Policies               : {}
Resources              : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; Health=; ID=F6566D6A-7468-46CF-B33B-E0F824681E66; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0; parentId=72DD24AA-E676-42B9-B991-01461764C08B}
State                  : 1
Subnets                : {@{AdditionalParams=; AddressPrefix=172.24.192.0/20; GatewayAddress=172.24.192.1; Health=; ID=37668DAD-A2B6-43D1-8FE1-B953CFD1A681; Policies=System.Object[]; State=0}}
TotalEndpoints         : 260
Type                   : NAT
Version                : 38654705669

I had to change the test image because I already had this one pulled. I am able to access the network fine, it's the second RUN command in a build that fails.

PS C:\Windows\system32> ctr run --rm --cni mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 cni-test curl -I example.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK
Content-Type: text/html
ETag: "84238dfc8092e5d9c0dac8ef93371a07:1736799080.121134"
Last-Modified: Mon, 13 Jan 2025 20:11:20 GMT
Cache-Control: max-age=1805
Date: Fri, 24 Jan 2025 14:05:07 GMT
Connection: keep-alive

nerddtvg avatar Jan 24 '25 14:01 nerddtvg

@profnandaa - I also sent you a message on the Docker Community Slack that might help.

nerddtvg avatar Jan 24 '25 14:01 nerddtvg

From your ctr run --cni run, seems to me there no issue with your CNI settings.

Fixed my CNI setup issues, I can repro this now. Let work on this on Monday. will respond to you on Slack and we can post back here the key findings for others.

My dockerfile:

FROM mcr.microsoft.com/windows/nanoserver:ltsc2019

RUN curl.exe -I example.com
RUN curl.exe -I bing.com
RUN curl.exe example.com

Build log:

#5 [2/4] RUN curl.exe -I example.com
#5 1.692   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#5 1.692                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
#5 1.910 HTTP/1.1 200 OK
#5 1.910 Cache-Control: max-age=792
#5 1.910 Content-Type: text/html
#5 1.910 Date: Sat, 25 Jan 2025 16:59:48 GMT
#5 1.910 Etag: "84238dfc8092e5d9c0dac8ef93371a07:1736799080.121134"
#5 1.910 Last-Modified: Mon, 13 Jan 2025 20:11:20 GMT
#5 1.910
#5 DONE 2.4s

#6 [3/4] RUN curl.exe -I bing.com
#6 ERROR: process "cmd /S /C curl.exe -I bing.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem z7ii51kg6icl3t9ota7se86my: The requested operation for attach namespace failed.
------
 > [3/4] RUN curl.exe -I bing.com:
------
Dockerfile:4
--------------------
   2 |
   3 |     RUN curl.exe -I example.com
   4 | >>> RUN curl.exe -I bing.com
   5 |     RUN curl.exe example.com
   6 |
--------------------
error: failed to solve: process "cmd /S /C curl.exe -I bing.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem z7ii51kg6icl3t9ota7se86my: The requested operation for attach namespace failed.

profnandaa avatar Jan 25 '25 17:01 profnandaa

cross-linking with an old issue here - https://github.com/containerd/containerd/issues/5729

profnandaa avatar Jan 27 '25 07:01 profnandaa

Another one - https://github.com/microsoft/hcsshim/issues/1822

profnandaa avatar Jan 27 '25 07:01 profnandaa

Hello, is there any workaround to this issue? I tried a --containerd-cni-pool-size=-1 workaround that I saw mentioned in another thread but it didn't seem to help.

I followed the instructions here: https://www.docker.com/blog/experimental-windows-containers-support-for-buildkit-released-in-v0-13-0/ https://github.com/moby/buildkit/blob/master/docs/windows.md#cni--networking-setup

Versions: buildkit - buildkitd github.com/moby/buildkit v0.26.3 c70e8e666f8f6ee3c0d83b20c338be5aedeaa97a containerd - containerd github.com/containerd/containerd v1.7.13 7c3aca7a610df76212171d200ca3811ff6096eb8 docker - Docker version 29.1.3, build f52814d

buildkit command:

buildkitd `
    --register-service `
    --service-name buildkitd `
    --containerd-cni-config-path="C:\Program Files\containerd\cni\conf\0-containerd-nat.conf" `
    --containerd-cni-binary-dir="C:\Program Files\containerd\cni\bin" `
    --containerd-cni-pool-size=-1 `
    --containerd-worker=true `
    --debug `
    --log-file="C:\Windows\Temp\buildkitd.log"

content of C:\Program Files\containerd\cni\conf\0-containerd-nat.conf:

{
    "cniVersion": "1.0.0",
    "name": "nat",
    "type": "nat",
    "master": "Ethernet",
    "ipam": {
        "subnet": "172.18.32.0/20",
        "routes": [
            {
                "gateway": "172.18.32.1"
            }
        ]
    },
    "capabilities": {
        "portMappings": true,
        "dns": true
    }
}
PS C:\> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
vEthernet (nat)           Hyper-V Virtual Ethernet Adapter             12 Up           00-15-5D-EF-1C-F1        10 Gbps
Ethernet                  Google VirtIO Ethernet Adapter                2 Up           42-01-0A-D1-70-54       100 Gbps


PS C:\> Get-HnsNetwork


ActivityId             : 226567AC-F198-4F09-BDE6-639F35F79046
AdditionalParams       :
CurrentEndpointCount   : 0
Extensions             : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=E9B59CFA-2BE1-4B21-828F-B6FBDBDDC017; IsEnabled=False; Name=Microsoft Azure VFP Switch Extension},
                         @{Id=EA24CD6C-D17A-4348-9190-09F0D5BE83DD; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags                  : 0
Health                 : @{AddressNotificationMissedCount=0; AddressNotificationSequenceNumber=0; InterfaceNotificationMissedCount=0; InterfaceNotificationSequenceNumber=0; LastErrorCode=0; LastUpdateTime=134104871819382546;
                         RouteNotificationMissedCount=0; RouteNotificationSequenceNumber=0}
ID                     : C2B356A6-4431-4C41-BC6E-46F17E733E1A
IPv6                   : False
LayeredOn              : D02D71B4-3C4D-45BD-A64E-3450A858610B
MacPools               : {@{EndMacAddress=00-15-5D-EF-1F-FF; StartMacAddress=00-15-5D-EF-10-00}}
MaxConcurrentEndpoints : 1
Name                   : nat
NatName                : ICS7CE0BF87-72D4-45E1-AD01-AE6AE233DCED
Policies               : {}
Resources              : @{AdditionalParams=; AllocationOrder=2; Allocators=System.Object[]; Health=; ID=226567AC-F198-4F09-BDE6-639F35F79046; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0;
                         parentId=157F177E-8CBB-47FA-B123-CFDF11D3F2DF}
State                  : 1
Subnets                : {@{AdditionalParams=; AddressPrefix=172.18.32.0/20; GatewayAddress=172.18.32.1; Health=; ID=D91796D9-4761-4793-96B7-67ED9B1BE6FE; Policies=System.Object[]; State=0}}
TotalEndpoints         : 17
Type                   : nat
Version                : 38654705669

buildkit logs:

time="2025-12-18T15:03:10Z" level=warning msg="CDI setup error C:\\ProgramData\\buildkitd\\cdi: failed to monitor for changes: GetFileAttributes: The system cannot find the file specified."
time="2025-12-18T15:03:10Z" level=debug msg="creating new network namespace sh9zit55v0rtlwmwfsvrtwkwy"
time="2025-12-18T15:03:10Z" level=debug msg="hcn::HostComputeNamespace::Create id="
time="2025-12-18T15:03:10Z" level=debug msg="hcn::HostComputeNamespace::Create JSON: {\"Type\":\"Guest\",\"SchemaVersion\":{\"Major\":2,\"Minor\":0}}"
time="2025-12-18T15:03:10Z" level=debug msg="finished creating network namespace sh9zit55v0rtlwmwfsvrtwkwy"
time="2025-12-18T15:03:10Z" level=debug msg="finished setting up network namespace sh9zit55v0rtlwmwfsvrtwkwy"
time="2025-12-18T15:03:10Z" level=debug msg="remote introspection plugin filters" filters="[type==io.containerd.runtime.v1 type==io.containerd.runtime.v2]"
time="2025-12-18T15:03:10Z" level=info msg="found worker \"zk2m77az2wphvcxt1wah86xrm\", labels=map[org.mobyproject.buildkit.worker.containerd.namespace:buildkit org.mobyproject.buildkit.worker.containerd.uuid:2e2634dd-40e3-444d-a5e8-d4e717e672a6 org.mobyproject.buildkit.worker.executor:containerd org.mobyproject.buildkit.worker.hostname:dennyso-test2 org.mobyproject.buildkit.worker.network:cni org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:windows], platforms=[windows/amd64]"
time="2025-12-18T15:03:10Z" level=info msg="found 1 workers, default=\"zk2m77az2wphvcxt1wah86xrm\""
time="2025-12-18T15:03:10Z" level=warning msg="currently, only the default worker can be used."
time="2025-12-18T15:03:10Z" level=info msg="running server on //./pipe/buildkitd"
time="2025-12-18T15:03:27Z" level=debug msg="session started" spanID=efb1e69927093d9e traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="session finished: <nil>" spanID=efb1e69927093d9e traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="resolve exporter docker with map[name:<image>]" spanID=5be7ffe91f53314e traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="session started" spanID=afc0623f0253ec1b traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="reusing ref for local: zlbp9zbrvz3r6e1e6w409n6al" span="[internal] load build definition from Dockerfile" spanID=b4956d2e19b93928 traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (1)"
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (2)"
time="2025-12-18T15:03:27Z" level=debug msg="diffcopy took: 11.8712ms" span="[internal] load build definition from Dockerfile" spanID=c11d83e1b84cb24c traceID=ea217d6c5452a2815d7f48aaeac7142c
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (1)"
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (2)"
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (1)"
time="2025-12-18T15:03:27Z" level=debug msg="Calling proc (2)"
...
process "powershell.exe -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $ExecutionPolicy = 'Bypass'; .\\script.ps1" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem jqkmafgcgttyh5y7qcgtuvad6: The requested operation for attach namespace failed.: unknown
7976 v0.26.3 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --containerd-cni-pool-size=-1 --containerd-worker=true --debug --log-file=C:\Windows\Temp\buildkitd.log
main.unaryInterceptor
	/src/cmd/buildkitd/main.go:735
google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1
	/src/vendor/google.golang.org/grpc/server.go:1234
github.com/moby/buildkit/api/services/control._Control_Solve_Handler
	/src/api/services/control/control_grpc.pb.go:289
google.golang.org/grpc.(*Server).processUnaryRPC
	/src/vendor/google.golang.org/grpc/server.go:1431
google.golang.org/grpc.(*Server).handleStream
	/src/vendor/google.golang.org/grpc/server.go:1842
google.golang.org/grpc.(*Server).serveStreams.func2.1
	/src/vendor/google.golang.org/grpc/server.go:1061
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1693

7976 v0.26.3 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --containerd-cni-pool-size=-1 --containerd-worker=true --debug --log-file=C:\Windows\Temp\buildkitd.log
github.com/moby/buildkit/solver/llbsolver/ops.(*ExecOp).Exec
	/src/solver/llbsolver/ops/exec.go:519
github.com/moby/buildkit/solver.(*sharedOp).Exec.func2
	/src/solver/jobs.go:1181
github.com/moby/buildkit/util/flightcontrol.(*call[...]).run
	/src/util/flightcontrol/flightcontrol.go:122
sync.(*Once).doSlow
	/usr/local/go/src/sync/once.go:78
sync.(*Once).Do
	/usr/local/go/src/sync/once.go:69
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1693

7976 v0.26.3 C:\Program Files\buildkit\buildkitd.exe --run-service --service-name buildkitd --containerd-cni-config-path=C:\Program Files\containerd\cni\conf\0-containerd-nat.conf --containerd-cni-binary-dir=C:\Program Files\containerd\cni\bin --containerd-cni-pool-size=-1 --containerd-worker=true --debug --log-file=C:\Windows\Temp\buildkitd.log
github.com/moby/buildkit/solver.(*edge).execOp
	/src/solver/edge.go:963
github.com/moby/buildkit/solver/internal/pipe.NewWithFunction[...].func2
	/src/solver/internal/pipe/pipe.go:78
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1693

time="2025-12-18T15:03:37Z" level=debug msg="session finished: <nil>" spanID=afc0623f0253ec1b traceID=ea217d6c5452a2815d7f48aaeac7142c

Hdom avatar Dec 18 '25 15:12 Hdom

@Hdom - Did you ever find a solution for this? I've tried the workaround in my setup as well, but no luck. I can always get the first RUN to work, but never the subsequent ones.

Dockerfile:

FROM mcr.microsoft.com/windows/servercore:1809

SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell", "-NonInteractive", "-NoProfile", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN ipconfig /all
RUN nslookup google.com
RUN ping google.com

ENTRYPOINT ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell", "-Command", "$sec = Get-Random -Minimum 10 -Maximum 100 ; Write-Host $sec ; Start-Sleep -Seconds $sec"]

nerdctl Error:

#6 [3/4] RUN nslookup google.com
#6 ERROR: process "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem i3m3j3hx1e78z0gwtjvc6pbax: The requested operation for attach namespace failed.
------
 > [3/4] RUN nslookup google.com:
------
Dockerfile:7
--------------------
   5 |
   6 |     RUN ipconfig /all
   7 | >>> RUN nslookup google.com
   8 |     RUN ping google.com
   9 |
--------------------
error: failed to solve: process "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem i3m3j3hx1e78z0gwtjvc6pbax: The requested operation for attach namespace failed.
time="2026-04-23T16:15:42-04:00" level=fatal msg="no image was built"

Buildkit log:

time="2026-04-23T16:15:42-04:00" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = process \"C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com\" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem i3m3j3hx1e78z0gwtjvc6pbax: The requested operation for attach namespace failed." spanID=610a37a27a3632c6 traceID=9a25a7e2ce155aca04c9df8cd77d3550
process "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell -NonInteractive -NoProfile -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nslookup google.com" did not complete successfully: failed to create shim task: hcs::CreateComputeSystem i3m3j3hx1e78z0gwtjvc6pbax: The requested operation for attach namespace failed.
4680 v0.28.1 C:\\tools\\buildkitd.exe --config C:\\tools\\buildkitd.toml --containerd-cni-config-path C:\var\lib\rancher\rke2\agent\etc\cni\net.d\0-containerd-nat.conf --containerd-cni-binary-dir C:\var\lib\rancher\rke2\bin --containerd-worker-addr \\.\pipe\containerd-containerd --addr npipe:////./pipe/buildkitd?sddl=D:(A;;GA;;;AU) --addr npipe:////./pipe/buildkitd --containerd-cni-pool-size=-1 --debug
main.unaryInterceptor
        /src/cmd/buildkitd/main.go:738
google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1
        /src/vendor/google.golang.org/grpc/server.go:1232
github.com/moby/buildkit/api/services/control._Control_Solve_Handler
        /src/api/services/control/control_grpc.pb.go:289
google.golang.org/grpc.(*Server).processUnaryRPC
        /src/vendor/google.golang.org/grpc/server.go:1428
google.golang.org/grpc.(*Server).handleStream
        /src/vendor/google.golang.org/grpc/server.go:1832
google.golang.org/grpc.(*Server).serveStreams.func2.1
        /src/vendor/google.golang.org/grpc/server.go:1063
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1693

4680 v0.28.1 C:\\tools\\buildkitd.exe --config C:\\tools\\buildkitd.toml --containerd-cni-config-path C:\var\lib\rancher\rke2\agent\etc\cni\net.d\0-containerd-nat.conf --containerd-cni-binary-dir C:\var\lib\rancher\rke2\bin --containerd-worker-addr \\.\pipe\containerd-containerd --addr npipe:////./pipe/buildkitd?sddl=D:(A;;GA;;;AU) --addr npipe:////./pipe/buildkitd --containerd-cni-pool-size=-1 --debug
github.com/moby/buildkit/solver/llbsolver/ops.(*ExecOp).Exec
        /src/solver/llbsolver/ops/exec.go:519
github.com/moby/buildkit/solver.(*sharedOp).Exec.func2
        /src/solver/jobs.go:1181
github.com/moby/buildkit/util/flightcontrol.(*call[...]).run
        /src/util/flightcontrol/flightcontrol.go:122
sync.(*Once).doSlow
        /usr/local/go/src/sync/once.go:78
sync.(*Once).Do
        /usr/local/go/src/sync/once.go:69
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1693

4680 v0.28.1 C:\\tools\\buildkitd.exe --config C:\\tools\\buildkitd.toml --containerd-cni-config-path C:\var\lib\rancher\rke2\agent\etc\cni\net.d\0-containerd-nat.conf --containerd-cni-binary-dir C:\var\lib\rancher\rke2\bin --containerd-worker-addr \\.\pipe\containerd-containerd --addr npipe:////./pipe/buildkitd?sddl=D:(A;;GA;;;AU) --addr npipe:////./pipe/buildkitd --containerd-cni-pool-size=-1 --debug
github.com/moby/buildkit/solver.(*edge).execOp
        /src/solver/edge.go:963
github.com/moby/buildkit/solver/internal/pipe.NewWithFunction[...].func2
        /src/solver/internal/pipe/pipe.go:78
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1693

Although, mine might be failing because I'm also trying to leverage rke2 on the same node.

bsnuggs1 avatar Apr 23 '26 20:04 bsnuggs1

@bsnuggs1 Unfortunately I did not, I just gave up on the idea. Let me know if you figure it out 🙏

Hdom avatar Apr 23 '26 20:04 Hdom

@Hdom You got it

Image

bsnuggs1 avatar Apr 23 '26 20:04 bsnuggs1

@Hdom - So after looking at the source, I think the "workaround" only works if you build the source from @profnandaa's PR. After pulling the changes locally and building the executable, --containerd-cni-pool-size=-1 worked! But the PR is quite behind; it would need to be rebased or cherry-picked to bring it up to the latest.

bsnuggs1 avatar Apr 27 '26 16:04 bsnuggs1

I can rebase this, if it helps.

On Mon, 27 Apr 2026 at 19:00, Brandon Snuggs @.***> wrote:

bsnuggs1 left a comment (moby/buildkit#5668) https://github.com/moby/buildkit/issues/5668#issuecomment-4328485273

@Hdom https://github.com/Hdom - So after looking at the source, I think the "workaround" only works if you build the source from @profnandaa's PR https://github.com/moby/buildkit/pull/5686. After pulling the changes locally and building the executable, --containerd-cni-pool-size=-1 worked! But the PR is quite behind; it would need to be rebased or cherry-picked to bring it up to the latest.

— Reply to this email directly, view it on GitHub https://github.com/moby/buildkit/issues/5668#issuecomment-4328485273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7ZENU62XMVVTJUDXRFQL4X5725AVCNFSM6AAAAACPODUQTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DGMRYGQ4DKMRXGM . You are receiving this because you were mentioned.Message ID: @.***>

--


Nandaa Anthony

profnandaa avatar Apr 27 '26 17:04 profnandaa

@profnandaa Thanks, it would help. For now, I don't mind using the PR as-is.

However, do you know if your changes are going to make it into an official release?

bsnuggs1 avatar Apr 27 '26 18:04 bsnuggs1