docs icon indicating copy to clipboard operation
docs copied to clipboard

Can you kill a container by name or ID or either?

Open fardok opened this issue 9 years ago • 9 comments

File: engine/reference/commandline/kill.md

what is it CONTAINER? - is it code or his name?

fardok avatar Jan 07 '17 15:01 fardok

CONTAINER stands for either a container id or container name.

ralphtheninja avatar Jan 07 '17 16:01 ralphtheninja

#dibs

scjane avatar Apr 17 '17 05:04 scjane

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 avatar Apr 17 '17 05:04 ashishkamat2791

@ashishkamat2791 Hi, here's my understanding:

  • docker kill forcibly stops running containers. By default, it sends the -s KILL signal even if you only run docker kill <container_id or container_name>; that is, docker kill <container_id or container_name> and docker 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 using docker ps -a and can be started again using docker start.
  • docker stop gracefully stops running containers. After running this command for a container, the container is exited but still exists, that is, it still can be seen using docker ps -a and can be started again using docker start.
  • docker rm removes containers. After running this command for a container, the container does not exist anymore. It cannot be seen using docker ps -a and thus cannot be started again using docker start.

scjane avatar Apr 19 '17 07:04 scjane

@scjane sounds like you have the info to fix this then!

mdlinville avatar Apr 19 '17 14:04 mdlinville

@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 avatar Apr 20 '17 04:04 scjane

@scjane that's the one! But do it in the master branch and make a note that it should be cherry-picked.

mdlinville avatar Apr 20 '17 19:04 mdlinville

Under review upstream. Thanks @scjane!

mdlinville avatar Apr 26 '17 17:04 mdlinville

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

docker-robott avatar Mar 05 '23 03:03 docker-robott