Docker Community Forums

Share and learn in the Docker community.

Docker for Windows Containers when user log off on host machine

Hi there!

I have some doubts about the strange behavior of docker containers when the user who executed them log off on the windows 10 host machine.

In short, the case is:

The active user runs docker-compose which consists of a linux container that has a port mapping XXXX:80. Everything works fine.

When the user logs out their session on the window 10 Host machine, the container automatically stops receiving http requests through the mapped port and does not reach the container.

The strange thing is that the container is always running (when the user logs in again this “Up” and for the time it indicates does not seem to have fallen at any time) but still does not allow any requests.

Has it happened to you? What could be the cause and above all… what is the solution?

Thank you, greetings.

1 Like

I have the same Problem

Did anyone ever work out why this is happening?
I’ve tried docker-compose and docker run both give me the same problems.

I can replicate this quite easily and it is blatantly deviating from correct behavior. Sad.

I have something very similar:
When I run a docker image with -ti for console usage, while Docker is switched to Windows, closing the CMD.exe Windows does not stop the shell/container running.
However, I can also not run CMD.exe again and try attach, since I did not use Ctrl-pq.

Only way to stop it appears to be docker restart, since docker stop just hangs.

In the case of no I/O, and port forwarding the docker Windows service would be running the container in the background, so it should have an environment not linked to the login. Did you use -net=host ?
You may also be able to get it to work by scheduling a one-time job to run the docker container, instead of starting it from CMD or Powershell. (untested, though :slight_smile: )

The Linux based docker appears to be more robust in these matters…