How do I keep a Docker stack running on Windows after I logout?

I’m running Docker Desktop version 3.3.0 on Windows 10 Enterprise 20H2. I have the same problem with both the WSL 2 and the Hyper-V backend: I can run a docker stack, but when I logout of Windows, Docker Desktop stops (“Linux Containers WSL 2 backend is stopping” is the notification), and so does my stack.

I’m using the sample stack from this tutorial: Deploy a stack to a swarm | Docker Documentation

I tried setting the deploy.restart_policy.condition to any in the docker-compose.yml file, but it doesn’t help.

I’ve looked high and low for a solution, but so far without luck, other than the suggestion: “Use Linux.” I’d love to, but unfortunately I need this to work on a Windows server.

Am I missing something obvious? Thanks.

I’ve run into the same problem, and can’t seem to find a resolution. I’ve been trying to serve a simple ‘hello world’ page with the httpd image, using WSL2 with Debian installed as the default distro. Page loads just fine, but as soon as I log out of Windows, no more requests are served. It seems like a serious problem that logging out of Windows would take down a container you are using as a web server…why can’t I find anything documenting this?

Docker Desktop for Windows is meant for development, not for a production web server. If you must use Windows for production you may want to look at ‘Mirantis Container Runtime’ (so, not offered by Docker). But for what Mirantis told me in December 2020, that does not run Linux containers.

If you insist on using Desktop, then in a previous job I have used Task Scheduler on Windows Server 2019 Data Center Edition to start it, and keep it running. Not at all recommended, obviously.