16

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.

codefire
  • 373
  • 1
  • 3
  • 13
  • 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

3 Answers3

24

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.

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • 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
9

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

monti
  • 644
  • 7
  • 14
-2

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

raka
  • 15
  • 2