blog-image

Apr 04, 2023

14 min read

How To Remove Docker Images, Containers, and Volumes

Written by

Abdelhadi Dyouri

Docker is an open-source platform for developing, shipping, and running applications. It is designed to make it easier to create, deploy, and run applications by using containers. With Docker, developers can package their applications into standardized units called containers, which can then be run on any computer, regardless of the operating system or hardware.

Docker allows developers to quickly and easily deploy their applications in a consistent environment, without having to worry about the underlying infrastructure. Docker also provides a rich set of tools and services for managing and monitoring applications, as well as for building and sharing images with other developers. Docker is an essential tool for modern software development, and it is used by many of the world's leading companies.

In this tutorial, you’ll learn how to remove Docker images, containers, and volumes to free up disk space on your system.

Prerequisites

  • Basic knowledge of the Linux command line.
  • An Ubuntu 22.04 server with a non-root user with sudo privileges. You can get affordable, and powerful Ubuntu servers from our website, and you can check out our How to access your server using SSH guide to learn how to access your server and create a sudo user.
  • Docker installed on your server. See How To Install and Use Docker on Ubuntu 22.04 to learn how to install Docker and use it to download images and run containers.

Pulling a Few Images from Docker Hub

Docker Hub is a cloud-based service that provides a centralized repository for Docker images. It allows users to store, manage, and share Docker images with other users. It provides a secure and reliable way to share and store Docker images, which can be used to create and deploy applications. Docker Hub also provides a wide range of services, such as private repositories, automated builds, and integration with other services.

To test whether you can access Docker Hub, run the hello-world image:

sudo docker run hello-world

You should receive an output that shows that your installation is working correctly:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:c77be1d3a47d0caf71a82dd893ee61ce01f32fc758031a6ec4cf1389248bb833
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

To demonstrate how to remove images and containers, we will first download a few images and use them to run containers.

For example, run the following command to download the official Ubuntu

Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply