How to batch Delete stopped containers in Docker

Source: Internet
Author: User

How to batch Delete stopped containers in Docker

How to batch Delete stopped containers in Docker

Method 1:
# Display all containers, filter out Exited containers, and retrieve the IDs of these containers,
# Sudo docker ps-a | grep Exited | awk '{print $1 }'
# Query all containers, filter out Exited containers, list container IDs, and delete these containers
# Sudo docker rm docker ps-a | grep Exited | awk '{print $1 }'

Method 2:
# Delete all containers that are not running (if they are not running, they will be deleted together)
# Sudo docker rm $ (sudo docker ps-a-q)

Method 3:
# Delete the Exited container Based on the container status
# Sudo docker rm $ (sudo docker ps-qf status = exited)

Method 4:
# After Docker 1.13, you can use the docker containers prune command to delete isolated containers.
Sudo docker container prune

# Deleting all images
Sudo docker rmi $ (docker images-q)

Figure:
02-delete all containers. All containers that are not running are deleted. Running containers cannot be deleted to delete unnecessary containers.
03-Docker versions earlier than 1.13 can be deleted based on the container status.
04-query all containers and filter out containers in the Exited status.
05-Docker 1.13 and later versions start to support the prune command to quickly delete the exited container
Delete all stopped containers:
# Docker system prune

02-delete all containers. All containers that are not running are deleted. Running containers cannot be deleted to delete unnecessary containers.

03-Docker versions earlier than 1.13 can be deleted based on the container status.

04-query all containers and filter out containers in the Exited status.

05-Docker 1.13 and later versions start to support the prune command to quickly delete the exited container
# Docker container prune

For more Docker tutorials, see the following:

Docker installation application (CentOS 6.5_x64)

Configure Docker on Ubuntu 16.04 Server

Install Docker in Ubuntu 15.04

Docker installation instance

Create a basic image using Docker

How to install Docker on Ubuntu 15.04 and its basic usage

Docker usage notes on Ubuntu 16.04

Use Docker to start common applications in minutes

Solution for changing the configuration file of Docker in Ubuntu 16.04 does not take effect

Docker details: click here
Docker: click here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.