Running containers don't stop with Ctrl + C

When I used Docker Desktop for experiment, I found a difference between Stopping with Ctrl+C Docker desktop for Windows and Docker for Linux.
I want to know the difference between them.

I created and run containers using following command using Docker desktop for Windows, and Docker for Linux (Ubuntu).

$ docker run --name test-nginx nginx

When I executed commands in Docker desktop for Windows, and I pressed Ctrl + c , expecting test-nginx container will stop.

But, I executed “docker ps” command, the result is following, it shows the container is not stopping.

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd097c54563e nginx “/docker-entrypoint.…” 2 minutes ago Exited (0) 2 minutes ago test-nginx

When I executed the same “docker run” commands in Docker in Linux, and I pressed Ctrl + c , the test-nginx container stopped. That’s the difference between Docker desktop for Windows and Docker for Linux.

Can’t reproduce this, neither in WSL nor in PowerShell.

This container is actually stopped (“Exited”) and what you get here is the output for docker ps -a. You should see the same when you enter this command on your Linux machine.

I don’t think there is a difference between the Windows and Linux editions. A container will remain available after shutdown unless you use --rm, i.e.

docker run --rm --name test-nginx nginx

That said, things can go wrong. I have experienced issues when the container doesn’t shut down correctly and remains available. The easiest solution is to run docker container prune now and again.

Found the same thing on my windows machine Port is still working after Ctrl+c even I did not provide the detached mode explicitly beside “docker ps -a” showing status is up.