Repository navigation
Unable to Use Compose with Windows Containers #3808
Copy link
Copy link
Open
Labels
area/composebugSomething isn't workingSomething isn't workingplatform/Windows/Non-WSL2Microsoft Windows (non-WSL2)Microsoft Windows (non-WSL2)
Description
Description
When running nerdctl compose up, by default a --hostname parameter is passed to nerdctl run which is invalid on Windows OS.
Steps to reproduce the issue
- Use a similar docker-compose.yaml file:
services: github: image: mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2019 isolation: hyperv platform: windows/amd64 restart: unless-stopped scale: 1 # Hostname gets set and causes problem
nerdctl compose up
Describe the results you received and expected
We would expect the container to be started successfully.
> nerdctl compose up
time="2025-01-10T18:35:02Z" level=warning msg="Ignoring: service github: [Isolation]"
time="2025-01-10T18:35:02Z" level=info msg="Ensuring image mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2019"
time="2025-01-10T18:35:02Z" level=info msg="Creating container runners-github-1"
time="2025-01-10T18:35:02Z" level=info msg="Running [C:\\Program Files\\nerdctl\\nerdctl.exe run --cidfile=C:\\Users\\user\\AppData\\Local\\Temp\\2\\compose-2714756652\\cid -l=com.docker.compose.project=runners -l=com.docker.compose.service=github -d --name=runners-github-1 --pull=never --net=runners_default --hostname=github --platform=windows/amd64 --restart=unless-stopped mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2019]"
time="2025-01-10T18:35:03Z" level=fatal msg="failed to verify networking settings: the following networking arguments are not supported on Windows: [--hostname]"
time="2025-01-10T18:35:03Z" level=fatal msg="error while creating container runners-github-1: error while creating container runners-github-1: exit status 1"
What version of nerdctl are you using?
nerdctl version
time="2025-01-10T18:36:06Z" level=warning msg="unable to determine runc version: exec: \"runc\": executable file not found in %PATH%"
Client:
Version: v2.0.2
OS/Arch: windows/amd64
Git commit: 1220ce7ec2701d485a9b1beeea63dae3da134fb5
buildctl:
Version: v0.18.2
GitCommit: e4da654b1251f91e914fab18eba33743aefd7080
Server:
containerd:
Version: v2.0.1
GitCommit: 88aa2f531d6c2922003cc7929e51daf1c14caa0a
runc:
Version:
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
Host information
Windows Server 2019
Microsoft Windows [Version 10.0.17763.6659]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/composebugSomething isn't workingSomething isn't workingplatform/Windows/Non-WSL2Microsoft Windows (non-WSL2)Microsoft Windows (non-WSL2)
Activity
apostasie commentedon Jan 24, 2025
Wondering if we should just null
m.netOpts.Hostnameand issue a warning instead of hard failing on it.@AkihiroSuda wdyt?
TinaMor commentedon Feb 24, 2025
@apostasie Tested this on Docker with the provided Compose file using WS22. I also tested with the hostname in the compose file and it worked.
Digging around the compose-spec/compose-go and docker/compose, there doesn't appear to be any explicit handling that marks
hostnameas an invalid field for Windows.Additional testing is required in nerdctl to determine the implications of explicitly setting the
hostnamevalue or allowing it to default to the service name, on Windows. This will help identify any potential restrictions from Compose or the underlying container runtime.apostasie commentedon Feb 24, 2025
Could it be a CNI plugins limitation on windows?
TinaMor commentedon Feb 24, 2025
Perhaps. But there have been some developments in the CNI-plugins since the code was written. Will test this using both microsoft/windows-container-networking and containernetworking/plugins. Not sure if nerdctl supports containernetworking/plugins yet for Windows.
TinaMor commentedon Mar 3, 2025
@apostasie Removed the
--hostnamefrom the nonZeroArgs. The error in #3808 is resolved, but then the hostname is not set correctly. Need to do further investigation on where the hostname value is set.Draft PR: https://github.com/containerd/nerdctl/pull/3963/files
Docker
nerdctl
apostasie commentedon Mar 3, 2025
Might want to try and see what happens on Windows when you do pass
--hostname(to figure out where this restriction is coming from).TinaMor commentedon Mar 3, 2025
--hostnameis not a valid flag for both nerdctl compose up and docker compose upapostasie commentedon Mar 3, 2025
Yep, so I guess the million dollar question is how do they set the hostname then...
apostasie commentedon Mar 3, 2025
Actually, is
docker run --hostnameallowed (not compose)?nerddtvg commentedon Mar 4, 2025
@apostasie - it shouldn't be a valid option but I can't test that at the moment. It is blocked in nerdctl run as well.
My original point of this issue was not to get hostname working, it was to stop compose from auto-appending a hostname for Windows containers when not specified.
Of course if the alternative was to get hostname working instead, that sounds better to me.
TinaMor commentedon Mar 17, 2025
Tagging containerd/discussions/9499
TinaMor commentedon Mar 18, 2025
After further investigation, we found that containerd does not persist the hostname or update the computer name for Windows containers when using both Docker + containerd and nerdctl + containerd.
Will continue investigating this issue within containerd.
ShadowLNC commentedon Mar 3, 2026
This is also my goal, since I don't care about the hostname in my context, is there a workaround I can put in my compose file to achieve this?
Obviously if we could get hostname working that'd be great, but currently it seems like I cannot use
nerdctl compose runat all due to this issue, so I was wondering if we could just disable hostname support in the interim (and then leave the issue open, albeit renamed).(I can use
nerdctl compose buildalready, albeit withoutpullorcache_tosupport.)bsnuggs1 commentedon May 7, 2026
There does not seem to be any updates on this issue. Is there a potential workaround that can be used? It seems like this issue really only affects WS2019 servers. I've encountered similar behaviour in testing.
mloskot commentedon Oct 20, 2026
following networking arguments are not supported on Windows: [--hostname]
It's been a while since the last update on this issue, and numerous versions have been released since,
My current stack on Windows Server 2022:
Here is my failing use case,
compose.yaml:Verification:
Run attempt: