As you keep creating new docker containers from images (without --rm option) you will see that you start accumulating stopped containers that take up space, you can check them by running the docker ps command with -a option.
Example:% docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e9072f3eff69 fedora "echo hello" 17 minutes ago Exited (0) 17 minutes ago thirsty_almeida
21abcc335be3 ubuntu "echo 12345" 17 minutes ago Exited (0) 17 minutes ago interesting_turing
0c0ba20b0018 fedora "echo hello" 18 minutes ago Exited (0) 18 minutes ago cool_robinson
If you do not need them and so to remove all the stopped containers we can make use of the docker container prune command,
Example:% docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
e9072f3eff695c461c505a00a8ec63037994daad1df6fd5e41ffa9c10fc26c42
21abcc335be31c6f95312a88bf22738cfe79fb735f864a5b3532f5cf439dbbe8
0c0ba20b00189a16c383d32fc61b9189beddbb6d94454ef9f5617315a95c9229
Total reclaimed space: 124B
Remove Containers based on time lasped since created using until filter
Prune all docker containers that were created 10 minutes from now using --filter option,
% docker container prune --filter "until=10m"
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
e9072f3eff695c461c505a00a8ec63037994daad1df6fd5e41ffa9c10fc26c42
Total reclaimed space: 0B
![Docker Delete All Stopped Containers using Prune Command Docker Delete All Stopped Containers using Prune Command](https://code2care.org/docker/remove-all-docker-stopped-containers-using-prune-command/images/Docker Delete All Stopped Containers using Prune Command.jpg)
If you do not want to see the prompt as you run the prune command you can make use of the -f or --force option.
Delete a specific Stopped Docker Container
If you want to remove a specific docker container you can make use of the docker rm command followed by the container name,
% docker rm charming_antonelli
charming_antonelli
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Install Docker on Mac using brew cask
- How to know the Docker Sandbox ID of a Container Network?
- How to Rename Docker Image with none TAG and REPOSITORY?
- How to know list of images available on your device
- Docker Alpine Linux and Apache2 Example
- Install Bash on Alpine Linux - Docker
- Docker Run Command Examples - Part 1
- Install the minimal Linux on Docker (only 5 mb Alpine Linux)
- [fix] docker: Error response from daemon: dial unix docker.raw.sock: connect: no such file or directory.
- Install RabbitMQ on Docker
- How to know docker Engine details
- [Fix] Docker Error response from daemon: manifest for :latest not found: manifest unknown
- How to stop and start a docker container
- How to create volume in Docker using Command
- How to know the Docker Engine Version
- [docker] Error response from daemon: No such container
- Install Docker for Mac using Home-brew Cask
- Docker - Incompatible CPU detected - M1/M2 Mac (macOS Sonoma)
- [fix] Docker Desktop App not starting on Mac (macOS)
- Unable to find image docker latest locally
- How to Stop/Cancel/kill docker image pull
- List of what's new in Docker 4.23
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac
- Docker - Running in Resource Saver mode
- Column Mode Editing in Notepad++ - NotepadPlusPlus
- Find MAC address of your laptop device - HowTos
- Rounded Images in Bootstrap framework - Bootstrap
- Setting and Updating AWS CLI Configuration - AWS
- Get the Complete Sha256 Container ID for Docker Run Command - Docker
- How to Center Align Image in Bootstrap - CSS
- How to fix Jenkins Plugin Stuck in Uninstallation pending Status - Linux
- Java Optional Util Class Examples - Java