{"id":5197,"date":"2026-04-06T09:59:44","date_gmt":"2026-04-06T09:59:44","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=5197"},"modified":"2026-04-06T09:59:55","modified_gmt":"2026-04-06T09:59:55","slug":"docker-clean-up-commands","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=5197","title":{"rendered":"Docker Image and Container Clean-Up Commands"},"content":{"rendered":"\n<p>Some commands you can use to clean up running containers and your images.<\/p>\n\n\n\n<p>Remove any containers, its recommended to verify if they are stopped first with &#8220;docker ps -a&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker rm $(docker ps -aq)<\/code><\/pre>\n\n\n\n<p>Remove all the images:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker rm $(docker images -q)<\/code><\/pre>\n\n\n\n<p>In my case I had a couple of images that needed to be force removed, you can&#8217;t remove images with the above method, if they are referenced in more than one repository at a time, i.e. in my case I had some that are locally stored, and one that was stored in DockerHub.<\/p>\n\n\n\n<p>A quick way to remove these is just to manually remove them by their image name, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker rmi $(docker images -q)\nUntagged: web_server_image:latest\nDeleted: sha256:414fb4fa561591b00474d09ae4b8eb24dfa7152d8f0e969388f4237b012631dc\nUntagged: hello-world:linux\nDeleted: sha256:b44f8077f3cc983f21adf071c813599ff805af75196a456a326253c7b3357c48\nUntagged: hello-world:latest\nDeleted: sha256:452a468a4bf985040037cb6d5392410206e47db9bf5b7278d281f94d1c2d0931\nError response from daemon: conflict: unable to delete 199b8a98ffde (must be forced) - image is referenced in multiple repositories\nError response from daemon: conflict: unable to delete 199b8a98ffde (must be forced) - image is referenced in multiple repositories<\/code><\/pre>\n\n\n\n<p>You can remove using the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker rmi $(docker images -q)\nUntagged: web_server_image:latest\nDeleted: sha256:414fb4fa561591b00474d09ae4b8eb24dfa7152d8f0e969388f4237b012631dc\nUntagged: hello-world:linux\nDeleted: sha256:b44f8077f3cc983f21adf071c813599ff805af75196a456a326253c7b3357c48\nUntagged: hello-world:latest\nDeleted: sha256:452a468a4bf985040037cb6d5392410206e47db9bf5b7278d281f94d1c2d0931\nError response from daemon: conflict: unable to delete 199b8a98ffde (must be forced) - image is referenced in multiple repositories\nError response from daemon: conflict: unable to delete 199b8a98ffde (must be forced) - image is referenced in multiple repositories<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker rmi simple_hello_world:latest\nUntagged: simple_hello_world:latest<\/code><\/pre>\n\n\n\n<p>And finally we can see it has removed one of them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker images\n                                                                                                                                                                                                               i Info \u2192   U  In Use\nIMAGE                                  ID             DISK USAGE   CONTENT SIZE   EXTRA\ngeekmungus\/simple_hello_world:v0.0.1   199b8a98ffde        117MB         29.7MB<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some commands you can use to clean up running containers and your images. Remove any containers, its recommended to verify if they are stopped first with &#8220;docker ps -a&#8221;: Remove all the images: In my case I had a couple of images that needed to be force removed, you can&#8217;t remove images with the above &#8230; <a title=\"Docker Image and Container Clean-Up Commands\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=5197\" aria-label=\"Read more about Docker Image and Container Clean-Up Commands\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":4496,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42,46],"tags":[],"class_list":["post-5197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-docker"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5197"}],"version-history":[{"count":2,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5197\/revisions"}],"predecessor-version":[{"id":5199,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/5197\/revisions\/5199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/media\/4496"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}