Home > Operation and Maintenance > Docker > What is the difference between kill and rm in docker

What is the difference between kill and rm in docker

WBOY
Release: 2022-01-17 09:27:12
Original
4046 people have browsed it

The difference between kill and rm in docker: 1. The kill command in docker will directly send the SIGKILL signal to kill the container, while the rm command will delete one or more containers; 2. The rm command will delete the generated files generated during the running of the container. data, and the kill command will not delete the data generated when the container is running.

What is the difference between kill and rm in docker

The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.

What is the difference between kill and rm in docker

docker rm: delete one or more containers.

Syntax

docker rm [OPTIONS] CONTAINER [CONTAINER...]
Copy after login

OPTIONS Description:

  • -f: Forcefully delete a running container through the SIGKILL signal.

  • -l : Removes network connections between containers, not the containers themselves.

  • -v : Delete the volume associated with the container.

Example

Force deletion of containers db01 and db02:

docker rm -f db01 db02
Copy after login

Remove the connection of container nginx01 to container db01, connection name db:

docker rm -l db
Copy after login

docker kill: Kill a running container.

Syntax

docker kill [OPTIONS] CONTAINER [CONTAINER...]
Copy after login

OPTIONS Description:

  • -s: Send a signal to the container

Example

Kill the running container mynginx

runoob@runoob:~$ docker kill -s KILL mynginx
mynginx
Copy after login

Docker rm will delete the data generated during the running of the container, but docker kill will not.

Recommended learning: "docker video tutorial"

The above is the detailed content of What is the difference between kill and rm in docker. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template