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

前端 未结 3 1241
小鲜肉
小鲜肉 2021-02-13 06:53

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 :

相关标签:
3条回答
  • 2021-02-13 07:48

    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

    0 讨论(0)
  • 2021-02-13 07:50

    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.

    0 讨论(0)
  • 2021-02-13 07:59

    docker update --restart=no <container>

    0 讨论(0)
提交回复
热议问题