Expected behavior
A Docker Desktop restart automatically stops all containers and should also disconnect any port listens.
Actual behavior
Instead, with Docker Desktop 3.3.1 (possibly earlier versions as well), a port will still be unavailable (occupied) after a docker desktop restart.
Information
This is easily reproducible on both arm64 and amd64 as below. It does not seem to be a problem on Windows (regular or WSL2, and it does not seem to be a problem on Linux.
- macOS Version: 11.3
- Intel chip or Apple chip: Same behavior with both M1 and Intel, amd64 and arm64
- Docker Desktop Version: 3.3.1
Steps to reproduce the behavior
docker run --name nginx -d -p 127.0.0.1:80:80 nginx
curl -I http://localhost or nc -vz localhost 80 will show that docker is listening on port 80.
- Restart docker desktop using the menu item
nc -vz localhost 80 will show that the listen port is still occupied. This means that the container cannot be restarted, nor can another container occupy port 80. As a result, docker desktop has to be restarted again to get port 80 cleared.
Removing the container with docker rm nginx does not solve this. You still have to restart docker desktop.
This doesn't seem to happen when binding to 0.0.0.0, so docker run --name nginx -d -p 80:80 nginx doesn't seem to cause this behavior.
Expected behavior
A Docker Desktop restart automatically stops all containers and should also disconnect any port listens.
Actual behavior
Instead, with Docker Desktop 3.3.1 (possibly earlier versions as well), a port will still be unavailable (occupied) after a docker desktop restart.
Information
This is easily reproducible on both arm64 and amd64 as below. It does not seem to be a problem on Windows (regular or WSL2, and it does not seem to be a problem on Linux.
Steps to reproduce the behavior
docker run --name nginx -d -p 127.0.0.1:80:80 nginxcurl -I http://localhostornc -vz localhost 80will show that docker is listening on port 80.nc -vz localhost 80will show that the listen port is still occupied. This means that the container cannot be restarted, nor can another container occupy port 80. As a result, docker desktop has to be restarted again to get port 80 cleared.Removing the container with
docker rm nginxdoes not solve this. You still have to restart docker desktop.This doesn't seem to happen when binding to 0.0.0.0, so
docker run --name nginx -d -p 80:80 nginxdoesn't seem to cause this behavior.