docker-composewindows-serverdocker-desktop

Running a Windows server container via docker-compose exits immediately


I'm trying to start a windows server via docker-compose, but can't seem to keep it running.

From what i can read the way to keep something like this running is by using ping -t as an entrypoint, but this doesn't work for me.

I can make it work in a simple docker run command

docker run mcr.microsoft.com/windows/server:ltsc2022 ping -t localhost

but my docker-compose file failed with the following:

Error response from daemon: container 0a78346ecd083493e85206f1fc255e5b31b0bcfa835268b1445be2cb769619ac encountered an error during hcs::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF723B000AD: (caller: 00007FF723AA4BB7) Exception(2) tid(3c4) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000]

my docker-compose file looks like this:

services:
  testserver:
    image: mcr.microsoft.com/windows/server:ltsc2022
    container_name: testserver
    entrypoint: ["cmd.exe /c ping -t localhost"]

This issue has stopped me from using docker to run test applications before, but it seems like it should be fairly simple to start af server from one of the images provided by MS.

i'm running docker for desktop, and the engine is set to windows containers.


Solution

  • Turns out i had you use "command" instead of "entrypoint"

    changed my docker-compose file, and now the container keeps running.

    version: '3'

    services:
      windows-server-container:
        image: mcr.microsoft.com/windows/server:ltsc2022
        container_name: testserver
        command: cmd /C "ping -t localhost > NULL"