Tutorials  /  Container & Cloud

How To Remove Docker Images, Containers, and Volumes

Ccentron Redaktion · January 2025 ·4 min read ·Container & Cloud, Tutorial

Introduction

Docker makes it easy to wrap your applications and services in containers so you can run them anywhere. However, as you work with Docker, it’s also easy to accumulate an excessive number of unused images, containers, and data volumes that clutter the output and consume disk space.

Docker gives you all the tools you need to clean up your system from the command line. This cheat sheet-style guide provides a quick reference to commands that are useful for freeing disk space and keeping your system organized by removing unused Docker images, containers, and volumes.

K8

Matching infrastructure at centron

From container to cluster: managed Kubernetes with cStack starts at €29.99 per month – control plane, autoscaler and traffic included. Explore managed Kubernetes →

How to Use This Guide

  • This guide is in cheat sheet format with self-contained command-line snippets.
  • Jump to any section that is relevant to the task you are trying to complete.
  • Note: The command substitution syntax, $(command), is available in many popular shells such as bash, zsh, and Windows Powershell.

Purging All Unused or Dangling Images, Containers, Volumes, and Networks

Docker provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not tagged or associated with a container):

Code
docker system prune

To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag:

Code
docker system prune -a

Removing Docker Images

Remove one or more specific images

Use the docker images command with the -a flag to locate the ID of the images you want to remove. Then use docker rmi to remove them:

Code
docker images -a
Code
docker rmi 

Remove dangling Docker images

To locate dangling images:

Code
docker images -f dangling=true

To remove them:

Code
docker image prune

Removing Containers

Remove one or more specific containers

Use docker ps -a to locate the containers you want to remove:

Code
docker ps -a
Code
docker rm 

Remove all exited containers

To locate exited containers:

Code
docker ps -a -f status=exited

To remove them:

Code
docker rm $(docker ps -a -f status=exited -q)

Removing Volumes

Remove one or more specific volumes

Use the docker volume ls command to locate volumes:

Code
docker volume ls

Then use docker volume rm to remove them:

Code
docker volume rm 

Remove dangling volumes

To locate dangling volumes:

Code
docker volume ls -f dangling=true

To remove them:

Code
docker volume prune

Conclusion to Remove Docker Images

This guide covers some of the common commands used to remove images, containers, and volumes with Docker.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Container & Cloud
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren