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

3

18

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.

Babbittry answered 3/12, 2014 at 22:47 Comment(2)
Have you tried docker kill?Bermuda
@Bermuda thaks! it's only one command that helped me!Sri
B
6

Many thanks for those who takes time to respond.

If you use docker directly, Bryan is right sudo docker rm -f container is enough.

My problem was mainly that I use puppet to deploy docker images and run containers. I use this module and it creates entries in /etc/init for the upstart process manager.

I think, my problem whas that, some kind of incompatibilities between the process manager and docker.

In this situation, to halt a container, simply sudo stop docker-container.

More informations on managing docker container run can be found on the docker website

Babbittry answered 4/12, 2014 at 15:5 Comment(2)
With the latest version of the docker puppet module containters script have been moved to /etc/init.d, so you need to : sudo /etc/init.d/docker-container-name stopBabbittry
you also can use: docker update --restart=no <container_name> check linkMesonephros
E
14

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.

Endways answered 4/12, 2014 at 10:58 Comment(1)
Ignore me. The problem was the container had been started by a service, and so always restarted until I killed the service itself.Churl
P
11

docker update --restart=no <container>

Palsy answered 15/2, 2019 at 1:5 Comment(0)
B
6

Many thanks for those who takes time to respond.

If you use docker directly, Bryan is right sudo docker rm -f container is enough.

My problem was mainly that I use puppet to deploy docker images and run containers. I use this module and it creates entries in /etc/init for the upstart process manager.

I think, my problem whas that, some kind of incompatibilities between the process manager and docker.

In this situation, to halt a container, simply sudo stop docker-container.

More informations on managing docker container run can be found on the docker website

Babbittry answered 4/12, 2014 at 15:5 Comment(2)
With the latest version of the docker puppet module containters script have been moved to /etc/init.d, so you need to : sudo /etc/init.d/docker-container-name stopBabbittry
you also can use: docker update --restart=no <container_name> check linkMesonephros

© 2022 - 2024 — McMap. All rights reserved.