I was trying rancher. I used the command: sudo docker run -d --restart=always -p 8080:8080 rancher/server to start run it. Then I stopped the container and removed it. But if I stop and restart the docker daemon or reboot my laptop, and lookup running containers using docker ps command, it will have rancher server running again. How do I stop/remove it completely and make sure it will not run again.
-
I tried to stop and remove all running containers, then stop and restart docker daemon to see if the container would start again. It keep on restarting in a different container id. I am not sure what was happening or if its a bug. I repeated stop remove step many times untill no containers was restarting. Now it seems to have stopped finally – codefire Aug 02 '16 at 09:01
5 Answers
Note: following issue 11008 and PR 15348 (commit fd8b25c, docker v1.11.2), you would avoid the issue with:
sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
In your current situation, thanks to PR 19116, you can use docker update
to update the restart policy.
docker update --restart=unless-stopped <yourContainerID_or_Name>
Then stop your container, restart your docker daemon: it won't restart said container.
The OP codefire points to another reason in the comments:
When I first ran the start rancher server command, I didn't notice that it was being downloaded. So I may have retried that command a couple times.
That must be why the job kept on restarting even after stopping and removing containers that was started as rancher server.
After stopping and removing 8+ containers, it finally stopped
That is why I have aliases to quickly remove any stopped containers.
-
yes, i tried that and did see that PR. When I first ran the start rancher server command, I didn't notice that it was being downloaded. So I may have retried that command a couple times. That must be why the job kept on restarting even after stopping and removing containers that was started as rancher server. After stopping and removing 8+ containers, it finally stopped. – codefire Aug 02 '16 at 16:53
-
@codefire OK. I have included your comment in the answer for more visibility. – VonC Aug 02 '16 at 18:26
it keeps restarting because you're using --restart=always
flag
Run
docker logs <CONTAINER_ID>
to see if your code is encountering any errors that does not allow the container to run properly

- 734
- 8
- 16
These solutions are correct! But for me there was a situation when these answers did not work out. That's because I was running service in the background I did not remove it so it keeps running even you remove container it will restart it again and so on... So answer to that specific problem is
docker service rm service name or id

- 69,473
- 35
- 181
- 253

- 569
- 6
- 9
Thanks for the answers, but for me even using the answer von VonC the problem continues. After researching Kubernetes was running the image again and again.
Use kubectl get nodes
to get the nodes u have and later run:
kubectl drain NODE_ID --delete-emptydir-data --ignore-daemonsets

- 465
- 3
- 7
-
That should work indeed. Kubernetes was still nascent back in 2016, when I wrote my answer. – VonC Oct 02 '22 at 00:05
-
Thanks @VonC. U help me a lot! That is why i've voted for your answer! :-) – harryssuperman Oct 05 '22 at 07:09
Docker run in your locahost if you shutdown/kill docker damen then docker stop and inside in docker container delete data if you not save your data in external volume.
docker run -d nginxlogs:/var/log/nginx -p 5000:80 nginx

- 25
- 2