How to stop a docker container which started with `--restart=always`
Here's the mighty eagle that docker has recently included. :D
You can update
docker container.
use sudo docker update --restart=no <container_id>
to update --restart
flag of the container.
Now you can stop
the container.
You should be able to just use docker stop and then docker rm to make sure the container doesn't restart when the daemon restarts.
Your question is an issue on the docker github and someone has made some comments about to how to solve here
I'm not sure if it's intended behavior to restart a stopped container on daemon restart... but for sure docker rm would be all that is needed, no need to remove the image.
If you use docker stop or docker kill, you're manually stopping the container so it will not restart. You can do some tests about restart policies: restarting the docker daemon, rebooting your server, using a CMD inside a container and running an exit...
See this answer for more details:
https://serverfault.com/a/884823/381420