I have just started using docker desktop recently, I’ve always used it on linux installations.
I have few container running on my windows 11 machine and no major issues really except for one container not starting with docker desktop after a windows restart even though I have restart = unless-stopped in docker compose file.
unless-stopped: Similar to always, except that when the container is stopped (manually or otherwise), it isn’t restarted even after Docker daemon restarts.
This should say “it is never restarted on Docker daemon (re)start”
There is (currently) no option to return the container to its previous run state on daemon start, only…
unless-stopped : container always remains stopped when the daemon starts
always : container is always started when the daemon starts
I don’t agree. When I restart my Linux servers, the Docker daemon is restarted, too. And all containers with restart: unless-stopped are started, that have been running before the restart.
The original issue was reported about Docker Desktop. I’m not sure what @sketchy2001 uses. And I honestly don’t remember how these restart policies are supposed to work. It was so long time ago when I relied on it, but yes, it would make more sense if “unless-stopped” would still start containers on daemon start unless there is a bug in Docker / Docker Desktop or anything unusual in the environment.
Not sure when this changed but I was using restart: unless-stopped and containers would indeed start when the daemon started. Now containers with that setting are always stopped when the daemon starts/restarts and restart: always is required to get the original behaviour.
Currently using Docker Desktop on Mac, v4.47.0. I am seeing the same behaviour on Intel and Apple Silicon versions
I remembered this topic, so I tried the restart policy on macOS and Windows 11. I could not reproduce any restart policy issue. I tried stopping and starting Docker Desktop from the command line using the docker client, I tried the GUI, and tried ebooting my machine and start Docker Desktop again. I tried with an nginx container using docker run and also a compose project. I also tried with mounting the docker socket just to check if there is any dependency that makes the policy fail when the docker socket is mounted.
The container always started when I started Docker DEsktop and my restart policy was “unless-stopped”.. Then I tried forwarding a port to it as in the first post. Nothing broke the restart policy.
I did not try all the possible combinations of starting and stopping Docker Desktop and using different backends and settings, so if anyone can find a combination of settings and steps that reproduces the issue, that could help a lot. Even if sharing here or even more useful when sharing also on Github. If the host is Windows, then here:
When Docker cE is used without Docker Desktop, that should be similar, since Docker CE is also in Docker DEsktop, so the policy should work the same way, but those kind of issues can also be shared in another repository