Linux · 2月 3, 2023 0

How to remove all Docker containers on Linux

内容纲要

Docker Containers can be used to run some applications in a lightweight way. we examine how to remove all containers.

List All Docker Containers

Before removing all containers we can list all containers.

$ docker ps -aq

How to Stop All Running Containers

Before removing all containers, we must stop all running containers in order to properly remove them. The docker stop command stops all containers.

$ docker stop $(docker ps -aq)

How to Remove All Containers

The docker rm command is used. All containers are specified with the $docker ps -aq command and provided to the “docker rm” command.

$ docker rm $(docker ps -aq)

With the following command, all images of the ship can be removed.

$ docker rmi $(docker images -q)
%d 博主赞过: