{"id":1851,"date":"2021-12-27T09:42:08","date_gmt":"2021-12-27T09:42:08","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=1851"},"modified":"2021-12-28T05:34:50","modified_gmt":"2021-12-28T05:34:50","slug":"docker-clean-in-bulk","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2021\/12\/27\/docker-clean-in-bulk\/","title":{"rendered":"Docker: Clean in Bulk"},"content":{"rendered":"\n<p class=\"has-drop-cap\">I will define the problem I was facing<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-large is-layout-flow wp-block-quote-is-layout-flow\"><p>Too many snapshots versions for the same image were there on my system<\/p><cite>Freaky developer<\/cite><\/blockquote>\n\n\n\n<p>So to delete there was one hard hack way of cleaning it all <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker system prune -f<\/code><\/pre>\n\n\n\n<p>That would have killed all the dangling images but still left many I wished cleaned.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Light bulb moment<\/h2>\n\n\n\n<p>So while pondering what to do which included manually going one by one, I thought of trying this<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1<\/h3>\n\n\n\n<p>List all the images I wished to delete and narrow down to the specific versions<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker image ls\n\n\/\/ Gave a long listing<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@samarthya ~]# docker image ls myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector \nREPOSITORY                                                      TAG                        IMAGE ID       CREATED          SIZE\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211227-0800   2ff1893f12dc   51 minutes ago   658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211226-0801   41516ac3d35b   25 hours ago     658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211225-0800   f0b1d434f8ff   2 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211224-0800   1a0e64e65e6e   3 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211223-1024   0f6426638df8   3 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211223-0800   c5afad3c4ad3   4 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211222-0800   cd45ff9d8ae9   5 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211221-0800   74f9e90099b0   6 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211220-0800   0e1b917654ac   7 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211219-0800   f7341845f1db   8 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211218-0800   79d6911c6ab9   9 days ago       658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211217-0922   e26236e6dbc9   10 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211217-0800   1b513e15af6b   10 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211216-1035   edc8e8a7cf12   10 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211216-0945   50a0755bb248   10 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211216-0800   61899dbefc88   11 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211215-0800   0376ceb8248e   12 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211214-1031   1527a2319dcc   12 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211214-0917   7dd6eb7a7382   13 days ago      658MB\nmyartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector   2.2-SNAPSHOT-211210-0916   b304d9979b4b   2 weeks ago      658MB<\/code><\/pre>\n\n\n\n<p>So I know I could get the listing, now if I just pipe this listing to the <code>docker rmi<\/code> it should work &amp; I tried the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@muntest001601 ~]# docker rmi -f `docker image ls myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector -q`\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector:2.2-SNAPSHOT-211227-0800\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector@sha256:b3b551ccb8d29ad713fc861e2fe105a7289d37e21cff4c902db07a602270e9ae\nUntagged: myartifactory.samarthya.me\/my-connector:2.2-SNAPSHOT\nDeleted: sha256:7153d9c5af71f8ab1c8e13e12d0f4950483bf4aaa6174709f7d1acc1dfbbab89\nDeleted: sha256:5d429c41cf582d9c0171e9e3dd3f6bb536b337ba84e4b28c908cb6b0d9b800ff\nDeleted: sha256:eb15a2cfecc1b94a96cd9f850404ebd2bbc0f5d61e6b6525f72a5290fe927421\nDeleted: sha256:65e53cf22b400bd45c3e59f830db99b89830c732e2caece1036dec33174d3132\nDeleted: sha256:99d887aa09ea61c49f1047526faf7bb534118720ea77308b4d8b1d1b96143b9d\nDeleted: sha256:ae210b60ea32790c0fccbdfd1067b3fcaa9a73ec255c71605edd48e88e62e20d\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector:2.2-SNAPSHOT-211226-0801\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector@sha256:bd7b869e78d45279a66936b53116e8e7c016707ca60c7578ffcf49bb62be7c25\nDeleted: sha256:fb04a750af2dad61e9d03a45a06ec0d32de233b67ce147e39337501f3f2ba6e2\nDeleted: sha256:cdfef45f754806478708a4ab676919b517d0d39a91bd8c7f33ec8bc026b76476\nDeleted: sha256:1249ed58b9173463a2a11897ae3328a5ec1d44965e9dc6ded56b2b69db827191\nDeleted: sha256:62d46db913565fc8b20f03ee7971a1f4cd1facfa09922dfa2c9c1189f3be275c\nDeleted: sha256:95b6effdca41891099d4677465e5a07a5f60529a4a5c1d12eabe05848ce50aae\nDeleted: sha256:c5f9b59d60e5097fcaa29212af49e9cd30155af49df707a7ab60e7d458074e0b\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector:2.2-SNAPSHOT-211225-0800\nUntagged: myartifactory.samarthya.me\/opendataconnector\/2.2\/my-connector@sha256:9126e9b4421cb0b6c13208a6ee3ddaedd212585ed88aeeb13927af86b564be72\n...<\/code><\/pre>\n\n\n\n<p>Result all the selected image versions were wiped clean!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I will define the problem I was facing Too many snapshots versions for the same image were there on my system Freaky developer So to delete there was one hard hack way of cleaning it all That would have killed all the dangling images but still left many I wished cleaned. Light bulb moment So [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1853,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[86,34],"tags":[212,213,82],"class_list":["post-1851","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-docker","category-technical","tag-clear","tag-delete","tag-docker","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=1851"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/1853"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=1851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=1851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=1851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}