single command to stop and remove docker container

前端 未结 11 1345
失恋的感觉
失恋的感觉 2021-01-30 15:17

Is there any command which can combine the docker stop and docker rm command together ? Each time I want to delete a running container, I need to execu

11条回答
  •  无人共我
    2021-01-30 15:58

    You can use :

    docker rm -f CONTAINER_ID
    

    It will remove the container even if it is still running.

    https://docs.docker.com/engine/reference/commandline/rm/

    You can also run your containers with --rm option, it will be automatically removed when stopped.

    https://docs.docker.com/engine/reference/run/#clean-up-rm

    Edit: The rm -f might be dangerous for your data and is best suited for test or development containers. @Bernard's comment on this subject is worth reading.

提交回复
热议问题