{"id":1158,"date":"2020-09-08T20:07:11","date_gmt":"2020-09-08T12:07:11","guid":{"rendered":"https:\/\/freeapp.sbs\/blog\/?p=1158"},"modified":"2025-04-01T16:29:38","modified_gmt":"2025-04-01T07:29:38","slug":"wskd2yp9rgt47dh","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2020\/09\/08\/wskd2yp9rgt47dh\/","title":{"rendered":"How to Remove Docker Images and Containers"},"content":{"rendered":"<h1 class=\"md-end-block md-heading md-focus\" style=\"font-size: 2.25em;margin-top: 1rem;margin-bottom: 1rem;position: relative;line-height: 1.2;cursor: text;border-bottom: 1px solid #eeeeee;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain md-expand\">How to Remove Docker Images and Containers<\/span><\/h1>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">Written by <\/span><span class=\"md-meta-i-c md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/author\/myadmin\/\"><span class=\"md-plain\">Rahul<\/span><\/a><\/span><span class=\"md-plain\">, Updated on January 24, 2019<\/span><\/p>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/tag\/docker\/\"><span class=\"md-plain\">Docker<\/span><\/a><\/span><span class=\"md-plain\">, <\/span><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/tag\/docker-containers\/\"><span class=\"md-plain\">Docker Containers<\/span><\/a><\/span><span class=\"md-plain\">, <\/span><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/tag\/docker-images\/\"><span class=\"md-plain\">Docker Images<\/span><\/a><\/span><\/p>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\">\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">In our previous tutorials you have learned about installation of Docker engine on <\/span><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/install-and-manage-docker-on-centos\/\"><span class=\"md-plain\">CentOS\/RHEL<\/span><\/a><\/span><span class=\"md-plain\"> and <\/span><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/install-and-manage-docker-on-ubuntu\/\"><span class=\"md-plain\">Ubuntu<\/span><\/a><\/span><span class=\"md-plain\"> operating system and pulled images from Docker hub. After that created containers with images. This tutorial will help you to remove unnecessary Docker images and containers from your host machine.<\/span><\/p>\n<ul class=\"ul-list\" style=\"margin: 0.8em 0px;padding-left: 30px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\" data-mark=\"-\">\n<li class=\"md-list-item\" style=\"margin: 0px;position: relative\">\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0px 0px 0.5rem;position: relative\"><span class=\"md-meta-i-c  md-link\"><a style=\"cursor: pointer;color: #4183c4\" href=\"https:\/\/tecadmin.net\/export-and-import-docker-containers\/\"><span class=\"md-plain\">How to Export and Import Docker Containers<\/span><\/a><\/span><\/p>\n<\/li>\n<\/ul>\n<h2 class=\"md-end-block md-heading\" style=\"font-size: 1.75em;margin-top: 1rem;margin-bottom: 1rem;position: relative;line-height: 1.225;cursor: text;border-bottom: 1px solid #eeeeee;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">Remove Docker Images<\/span><\/h2>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">To remove an images, Docker provides <\/span><span class=\"md-pair-s\"><code style=\"font-family: var(--monospace);vertical-align: initial;border: 1px solid #e7eaed;background-color: #f3f4f4;border-radius: 3px;padding: 0px 2px;font-size: 0.9em\">**rmi**<\/code><\/span><span class=\"md-plain\"> option. Using this we can delete any docker images from our local system. For example use below command with changing &#8220; with your Docker image id.<\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker rmi &lt;IMAGE ID&gt;<\/span><\/pre>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">To list all available docker images on your system use the following command. This will help you to find the ID of images.<\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker images<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\"><span>\u200b<\/span><\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">REPOSITORY \u00a0 \u00a0 TAG \u00a0 \u00a0 \u00a0  IMAGE ID \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  CREATED \u00a0 \u00a0 \u00a0 \u00a0  VIRTUAL SIZE<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">centos \u00a0 \u00a0 \u00a0 \u00a0 latest \u00a0 \u00a0 2933d50b9f77 \u00a0 \u00a0 \u00a0  11 days ago \u00a0 \u00a0  196.6 MB<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">ubuntu \u00a0 \u00a0 \u00a0 \u00a0 latest \u00a0 \u00a0 36248ae4a9ac \u00a0 \u00a0 \u00a0  11 days ago \u00a0 \u00a0  188 MB<\/span><\/pre>\n<h2 class=\"md-end-block md-heading\" style=\"font-size: 1.75em;margin-top: 1rem;margin-bottom: 1rem;position: relative;line-height: 1.225;cursor: text;border-bottom: 1px solid #eeeeee;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">Remove Docker Containers<\/span><\/h2>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">To remove a containers, Docker provides <\/span><span class=\"md-pair-s\"><code style=\"font-family: var(--monospace);vertical-align: initial;border: 1px solid #e7eaed;background-color: #f3f4f4;border-radius: 3px;padding: 0px 2px;font-size: 0.9em\">**rm**<\/code><\/span><span class=\"md-plain\"> option. Using this we can delete any docker containers from our local system. For example use below command with changing &#8220; with your Docker container id.<\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker rm &lt;CONTAINER ID&gt;<\/span><\/pre>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">To list all containers on your system using <\/span><span class=\"md-pair-s \"><strong>ps<\/strong><\/span><span class=\"md-plain\"> option, but ps will show only running containers. So to view all containers use <\/span><span class=\"md-pair-s \"><strong>-a<\/strong><\/span><span class=\"md-plain\"> parameter with ps.<\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker ps -a<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\"><span>\u200b<\/span><\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">CONTAINER ID \u00a0 IMAGE \u00a0  COMMAND \u00a0 \u00a0  CREATED \u00a0 \u00a0 \u00a0 STATUS \u00a0 \u00a0  PORTS  NAMES<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">f2582758af13 \u00a0 ubuntu \u00a0 \"\/bin\/bash\"  2 hours ago \u00a0 Up 2 hours \u00a0 \u00a0 \u00a0 \u00a0 first_ubuntu<\/span>\n<span style=\"padding-right: 0.1px\" role=\"presentation\">2b199b9976c4 \u00a0 centos \u00a0 \"\/bin\/bash\"  3 days ago \u00a0  Up 3 hours \u00a0 \u00a0 \u00a0 \u00a0 thirsty_yalow<\/span><\/pre>\n<h2 class=\"md-end-block md-heading\" style=\"font-size: 1.75em;margin-top: 1rem;margin-bottom: 1rem;position: relative;line-height: 1.225;cursor: text;border-bottom: 1px solid #eeeeee;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">Stop &amp; Remove All Docker Containers<\/span><\/h2>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-plain\">To remove all docker containers from your system use the following commands. The first command will stop all running Docker containers and then the second command will delete all docker containers from your system.<\/span><\/p>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-pair-s \"><strong>Stop All Containers<\/strong><\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker stop $(docker ps -a -q)<\/span><\/pre>\n<p class=\"md-end-block md-p\" style=\"line-height: inherit;margin: 0.8em 0px;position: relative;font-family: 'Open Sans', 'Clear Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif\"><span class=\"md-pair-s \"><strong>Remove All Containers<\/strong><\/span><\/p>\n<pre class=\"md-fences md-end-block ty-contain-cm modeLoaded\" lang=\"\" style=\"overflow: visible;font-family: var(--monospace);font-size: 0.9em;background-image: inherit;background-position: inherit;background-size: inherit;background-repeat: inherit;background-attachment: inherit;background-color: #f8f8f8;border-color: #e7eaed;border-radius: 3px;padding: 8px 4px 6px;margin-bottom: 15px;margin-top: 15px;width: inherit;position: relative !important\"><span style=\"padding-right: 0.1px\" role=\"presentation\">docker rm $(docker ps -a -q)<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to Remove Docker Images and Containers Written by Rahul, Updated on January 24, 2019 Docker, Docker Containers, Docker Images In our previous tutorials you have learned about installation of Docker engine on CentOS\/RHEL and Ubuntu operating system and pulled images from Docker hub. After that created containers with images. &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-1158","post","type-post","status-publish","format-standard","hentry","category-ayo0bcjn5seq2"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/1158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=1158"}],"version-history":[{"count":2,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"predecessor-version":[{"id":3855,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/1158\/revisions\/3855"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}