How can I stop and delete a docker container launched with restart always option?

mperrin picture mperrin · Dec 3, 2014 · Viewed 14.7k times · Source

I run some containers with the option --restart always.

It works good, so good, that I have now difficulties to stop these containers now :)

I tried :

sudo docker stop container && sudo docker rm -f container

But the container still restarts.

The docker documentation explains the restart policies, but I didn't find anything to resolve this issue.

Answer

Bryan picture Bryan · Dec 4, 2014

Just

sudo docker rm -f container

will kill the process if it is running and remove the container, in one step.

That said, I couldn't replicate the symptoms you described. If I run with --restart=always, docker stop will stop the process and it remains stopped.

I am using Docker version 1.3.1.