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

What is the difference between rm and rmi in docker?

WBOY
WBOYOriginal
2022-07-14 11:02:115991browse

The difference between rm and rmi in docker: the rm command is used to delete one or more containers, and the rmi command is used to delete one or more mirrors; the syntax of the rm command is "docker rm [OPTIONS] CONTAINER [ CONTAINER...]", the syntax of the rmi command is "docker rmi [OPTIONS] IMAGE [IMAGE...]".

What is the difference between rm and rmi in docker?

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

What is the difference between rm and rmi in docker

docker rm: Delete one or more containers.

Syntax

docker rm [OPTIONS] CONTAINER [CONTAINER...]

OPTIONS Description:

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

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

-v : Delete the volume associated with the container.

The example is as follows:

Forcibly delete containers db01 and db02:

docker rm -f db01 db02

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

docker rm -l db

Delete the container nginx01, and delete the data volume mounted by the container:

docker rm -v nginx01

docker rmi: Delete one or more local mirrors.

Syntax

docker rmi [OPTIONS] IMAGE [IMAGE...]

OPTIONS description:

-f: force deletion;

--no-prune: do not remove the image Process image, removed by default;

Examples are as follows:

Forcibly delete the local image runoob/ubuntu:v4.

root@runoob:~# docker rmi -f runoob/ubuntu:v4
Untagged: runoob/ubuntu:v4
Deleted: sha256:1c06aa18edee44230f93a90a7d88139235de12cd4c089d41eed8419b503072be
Deleted: sha256:85feb446e89a28d58ee7d80ea5ce367eebb7cec70f0ec18aa4faa874cbd97c73

Recommended learning: "docker video tutorial"

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

Statement:
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