Can you kill a container by name or ID or either?
CONTAINER stands for either a container id or container name.
#dibs
Hi @mstanleyjones
I checked by running commands. It does not kill as it supposed to but just stop the running container and shows as exited
I think we need to pass the signal using -s flag for docker kill to completely remove container which can be achieved using docker rm -f CONTAINER-ID/CONTAINER-NAME for a single container and docker rm -f $(docker ps ) for all running containers and `docker rm -f $(docker ps -aq) for all running as well as dead containers
@ashishkamat2791 Hi, here's my understanding:
docker killforcibly stops running containers. By default, it sends the-s KILLsignal even if you only rundocker kill <container_id or container_name>; that is,docker kill <container_id or container_name>anddocker kill -s KILL <container_id or container_name>work the same way. After running this command for a container, the container is exited but still exists, that is, it still can be seen usingdocker ps -aand can be started again usingdocker start.docker stopgracefully stops running containers. After running this command for a container, the container is exited but still exists, that is, it still can be seen usingdocker ps -aand can be started again usingdocker start.docker rmremoves containers. After running this command for a container, the container does not exist anymore. It cannot be seen usingdocker ps -aand thus cannot be started again usingdocker start.
@scjane sounds like you have the info to fix this then!
@mstanleyjones I think we can add information in the "Extended Desciption" section referring that a container can be killed by its ID or name using this command, as the "docker attach" page does, as shown in the following figure. ![155](https://cloud.githubusercontent.com/assets/25146885/25212798/3b6e79dc-25bf-11e7-89a1-bae9643dc258.jpg
Is this the file to be editted?https://github.com/moby/moby/edit/17.03.x/docs/reference/commandline/kill.md
@scjane that's the one! But do it in the master branch and make a note that it should be cherry-picked.
Under review upstream. Thanks @scjane!
Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.
If you have found a problem that seems similar to this, please open a new issue.
/lifecycle locked