Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Storage » Kill Containers and remove unused images from Docker Correctly
  • GitLab runner update and upgrade
    How to update Gitlab-runners on Windows Windows
  • 1 WeXxkEX0JG3oB781HD8Hrg 3
    Fix Access denied to the hard drive, and the security tab missing under properties Windows Server
  • AzureCloudShell
    Provisioning Azure Resources using Azure Az PowerShell Cmdlet from Cloud Shell AWS/Azure/OpenShift
  • How to Fix Windows Stuck on System Restore
    How to Fix Windows Stuck on System Restore Windows
  • UpdateOfficeOnlineServer 1
    Perform Office Online Server Update via Windows Updates Windows Server
  • Screenshot 2020 06 22 at 22.46.00
    How to use a dedicated MsSQL Db for Pleasant Password Oracle/MSSQL/MySQL
  • Convert MP4 to MP3
    2 Free Ways to Convert MP4 to MP3 Reviews
  • how to install ms office 365 title
    How to complete Microsoft Office 365 Family Subscription Mac

Kill Containers and remove unused images from Docker Correctly

Posted on 24/09/202424/09/2024 Christian By Christian No Comments on Kill Containers and remove unused images from Docker Correctly
removing containers and unused images from Docker-synology

In this article, we shall discuss how to destroy, that is “Kill Containers and remove unused images from Docker Correctly”. We will be doing this over Portainer and Container Manager. Containers and images that are no longer in use can create clutter, making it harder to manage Docker environments. By removing them, you can streamline the system, keeping only essential resources running. Please see User account and process management in Linux, and Task Kill vs Stop Process: How to search for a service PID.

Note: Also, Docker containers, images, and networks take up significant disk space. Over time, unused or stopped containers, old images, and orphaned volumes can accumulate. Removing them helps free up space, especially on limited-storage devices like NAS

Kill Containers (CTs) over Portainer

In this article “Docker Setup: Monitoring Synology with Prometheus and Grafana“, we have discussed what Portainer is. For me, none of the reasons stated above apply.

I have decided to kill and remove unused images due to misconfiguration. Removing and recreating Containers can resolve configuration problems. Therefore, destroying and redeploying CTs allows you to reset the environment and apply new configurations without lingering issues from previous setups.

To do this, navigate to the Portainer dashboard, select the Containers you wish to destroy.

Kill containers
I will leave Portainer out for now as I wish to show you how to clean docker correctly via Portainer and as well as the Container Manager.

As you can see below, the containers are associated with the error code “Exited Code 137”. This error means that the container was terminated due to an out-of-memory (OOM) event. This means the system running the container did not have enough memory to continue running it, so the Linux kernel’s OOM killer forcibly stopped the process to free up memory.

To remove these containers that have been terminated, please select them and click “Remove”.

remove conatiners

Please confirm “Remove” as shown below.

confirm container removal

As you can see, the containers (CTs) have been removed.

removed

Remove Unused Images

Unused images are images that are not associated with any running or stopped container.

To remove unused images in Portainer, navigate to Images on the dashboard. Click on the Filter and select unused as shown below.

Clean unused images

Select the unused images and click on Remove.

remove unused images via Portainer

Confirm image(s) removal as shown below.

confirm image removal
You can also use the Docker CLI command directly to remove all unused images, not just from Portainer

As you can see, we have successfully removed all unused images.

Images removed

Remove Unused Network

To do this, navigate to the Network section from the Portainer dashboards. Go through the list of networks and identify unused networks. These are networks that are not connected to any active containers.

Check the box next to the networks you want to remove. Once you have selected the networks. Click the “Remove” button from the networks list.

remove nwtork

Confirm the action when prompted. This will permanently delete the selected networks from your system.

confirm network removal

Clean up Registry

Cleaning up registries is an important maintenance task for managing Docker images and containers as it helps free up storage space.

Note: For cloud-based registries, reducing storage usage can also lower costs associated with storage services. Also, it can increase performance as a cluttered registry can slow down operations such as pulling and pushing images. Regular cleanup can improve the performance of these operations by reducing the amount of data to manage

To do this, navigate to the Portainer dashboard and select the Registries you wish to remove.

Clear registry
In some environments, maintaining a clean and minimal registry can help meet compliance standards regarding security and data management.

On the prompt, please click on “Remove” to permanently delete the selected registries.

Remove registry

Delete Stacks

As you are probably aware of, during testing phase. You may need to frequently create and delete stacks. Removing outdated or unnecessary stacks helps streamline the testing process.

To do this, navigate to Stacks on the Portainer dashboard and select the Stacks to delete.

remove stack

Click on “Remove” as shown below when prompted.

Confirm stack removal

If you wish, you may need to clean up some persistent folder that were crated for your containers.

delete stalled files

Delete Container over Container Manager on Synology

As you can see, we currently have one image and Container running.

One container left

If we had deleted this over Portainer itself. I will not be able to show you all the steps I have demonstrated above.

To do this over the Container Manager, click on “Container” and ensure it is stopped. Next, select “Actions” and click on “Delete”.

You could stop and remove portainer via the container manager

Also, to remove the unused Poratainer image. In the left sidebar, click on “Images” and select the image to remove.

Then click on “Remove Unused Images”.

remove unsed image

Conclusion

You have learned how to effectively manage and remove unused images, network and containers via Portainer and Container Manager. Thereby, helping to maintain a clean and efficient Docker environment.

Regular maintenance helps ensure that you only retain necessary images, improving overall system reliability and resource management as well.

I hope you found this article on how to ‘Kill Containers and remove unused images from Docker Correctly” very useful. Please feel free to leave a comment below.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Pocket (Opens in new window) Pocket
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Storage Tags:docker cli

Post navigation

Previous Post: Monitoring Synology with Prometheus and Grafana
Next Post: How to create a Dev Drive on Windows 11

Related Posts

  • Synology NFS Share
    Add Synology NFS Storage to Proxmox VE for VMs and Backups Storage
  • How to manage user permission in AD and Synology
    Manage User Permission on Synology with Active Directory [Part 1] Reviews
  • Protech Synology NAS
    Cybersecurity Tips to Secure Synology NAS against Ransomware Reviews
  • Synology NAS as a Backup Repository for VBR
    Setup DS923+ Synology NAS as a Backup Repository for VBR Reviews
  • DS923   what is taking up my space
    What is taking up by Synology NAS Volume Space Storage
  • Object First Appliance unboxing
    Object First OOTBI Appliance Unboxing and Quick Setup Backup

More Related Articles

Synology NFS Share Add Synology NFS Storage to Proxmox VE for VMs and Backups Storage
How to manage user permission in AD and Synology Manage User Permission on Synology with Active Directory [Part 1] Reviews
Protech Synology NAS Cybersecurity Tips to Secure Synology NAS against Ransomware Reviews
Synology NAS as a Backup Repository for VBR Setup DS923+ Synology NAS as a Backup Repository for VBR Reviews
DS923   what is taking up my space What is taking up by Synology NAS Volume Space Storage
Object First Appliance unboxing Object First OOTBI Appliance Unboxing and Quick Setup Backup

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • GitLab runner update and upgrade
    How to update Gitlab-runners on Windows Windows
  • 1 WeXxkEX0JG3oB781HD8Hrg 3
    Fix Access denied to the hard drive, and the security tab missing under properties Windows Server
  • AzureCloudShell
    Provisioning Azure Resources using Azure Az PowerShell Cmdlet from Cloud Shell AWS/Azure/OpenShift
  • How to Fix Windows Stuck on System Restore
    How to Fix Windows Stuck on System Restore Windows
  • UpdateOfficeOnlineServer 1
    Perform Office Online Server Update via Windows Updates Windows Server
  • Screenshot 2020 06 22 at 22.46.00
    How to use a dedicated MsSQL Db for Pleasant Password Oracle/MSSQL/MySQL
  • Convert MP4 to MP3
    2 Free Ways to Convert MP4 to MP3 Reviews
  • how to install ms office 365 title
    How to complete Microsoft Office 365 Family Subscription Mac

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,832 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.