| I would like to disagree at a higher level. The obfuscatingly named (a hash of some sort) images are being created by Jenkins and because they are using such an obfuscating name as a hash makes trying to manage the accumulation of them outside of Jenkins difficult at best. For example, to go along with the idea that it is up to me, the admin (or a script I write) to remove old, no-longer used images, which represent past iterations of {{Dockerfile}}s in my pipeline jobs, which of the following images are current and which are older iterations?
# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> ff479182ebeb 4 days ago 1.42 GB
a831c15b87dbd4231d6947a16cb3a9af816cbd8d latest ac3742854a96 4 days ago 1.42 GB
e8cd3c8b78088b6c52ee705ae10be4201359a5b3 latest ac3742854a96 4 days ago 1.42 GB
4249d3c8084d55fc3d2a99132a0f9bce66f6e5ec latest ac3742854a96 4 days ago 1.42 GB
8447a9d1402c6562bdfc27950aada59b7b1e0593 latest ce155bde643b 4 days ago 1.62 GB
a1a0b41dfa855a77be010b372402702114bc1225 latest ce155bde643b 4 days ago 1.62 GB
a677138400e3274c0f3ccacb0d6919a892df06fb latest ce155bde643b 4 days ago 1.62 GB
280f646bcd85076af3f7cb58afc3c221a426ad4c latest 60e033d80253 4 days ago 1.76 GB
a2ec752628e0decf2e09a39fabfd1e08afdbe67f latest 60e033d80253 4 days ago 1.76 GB
cbc1131e470e384e815c278b456f8ce695657a89 latest 60e033d80253 4 days ago 1.76 GB
24e62ec336d1449f98fb7474a8496af0707c0588 latest caf0d9564161 7 days ago 1.42 GB
c761e9f12da336e348736f8c32e83e53d0c41ae4 latest caf0d9564161 7 days ago 1.42 GB
0b0baa88ac6d8ca0e4d1ec58b8d8ee475ba0978b latest 1b923c4a3d19 7 days ago 1.45 GB
79f5fc427029a540383e43637806c27ff56af029 latest 9515ddc1f273 7 days ago 1.6 GB
<none> <none> af1113a0c00c 7 days ago 1.6 GB
<none> <none> 1622a837d8b6 3 weeks ago 1.62 GB
46807bbb74e92fbdbe56fced9c109b8ed0367036 latest 353bbbbb4f1b 3 weeks ago 1.62 GB
d7c383939c4a517002774159d046d7f310f881c8 latest 353bbbbb4f1b 3 weeks ago 1.62 GB
4942b00624bbc67cb2ac9c1832200ce421962c2d latest 3c768e8f5305 3 weeks ago 1.58 GB
8b18a2c252deea8b6901d61877a13bd7567ba2f5 latest 40039dfa6469 3 weeks ago 1.6 GB
7b402774ab1d76f7d3a240f53780cee70a2da39c latest 78cd8f4f275e 4 weeks ago 1.55 GB
d2c8168b9d4e27bd0426deb78972664c19e97e8b latest 0ae5d7965ca6 4 weeks ago 1.61 GB
56043f81efbf7289d621c112b82933220763fbb4 latest 340fddd2839f 4 weeks ago 1.45 GB
115282b91e727adbf38cdeb8cdf6c1ef98be6593 latest 0b600893851a 4 weeks ago 1.41 GB
3163e91161e120ac113c2f191742689178ae01ee latest e1d8225a6c03 4 weeks ago 1.44 GB
6d5d2a2d75e1825fd624ceddfabaabc3d2dcbeb1 latest e1d8225a6c03 4 weeks ago 1.44 GB
65fbd7397d29d5649e5ac73664aeab9eedde969b latest 2563f445defd 4 weeks ago 1.69 GB
f880bb025268313fbd2fa186d75498129f92b622 latest 2563f445defd 4 weeks ago 1.69 GB
e4858d566cbee1aa9779ab329d4582e27ee74e4f latest d474affa1aeb 4 weeks ago 1.28 GB
0120a36aba35ee597208a684226d44cb569f0d43 latest c76105e5b17a 4 weeks ago 1.28 GB
dba890385ab8e5f278e432b53354dd96065e44b9 latest c76105e5b17a 4 weeks ago 1.28 GB
b449ce5eb8b256896bddfb05bd7bfc5befaabf5c latest 6ef942624bea 4 weeks ago 1.28 GB
1b063af35c6d4599b83d38e8c334afc65418bedf latest 0e664a829edf 4 weeks ago 1.42 GB
3bb0bab0fc5d15716dc2f627b18e6f9abec9cfd1 latest 0e664a829edf 4 weeks ago 1.42 GB
cc1c942fc9549340d5ce3be06d919383a8061e32 latest de6d4a254a9e 4 weeks ago 1.76 GB
efead29d4ffb6d190a8c1bf6dc7766ea3602a254 latest de6d4a254a9e 4 weeks ago 1.76 GB
420ccccaddd961b589a120c469c12fc5b05efa05 latest de6d4a254a9e 4 weeks ago 1.76 GB
477f7235e5c153a6fcc264835796b1325cb0f385 latest de6d4a254a9e 4 weeks ago 1.76 GB
96e98347f4b9891e7f31b15a28e1ac4c92745fdd latest 04cb6a316283 5 weeks ago 1.14 GB
docker.io/opensuse/leap 15.0 fc31f6f2561c 5 weeks ago 102 MB
465f4e0140a0bcb68c294b5803310684ea138248 latest 345377cec85c 5 weeks ago 1.29 GB
39ca2b5b6025114172753539f2761622c4712258 latest 55e801d57ebb 5 weeks ago 1.29 GB
435a6237a036627061bebf02de62396897fa04df latest a107ca16dda1 5 weeks ago 1.29 GB
138305b687cc264df7f5d3576aa16ce9f3e6b86b latest 828a27a31e21 5 weeks ago 1.46 GB
3cd3e822a10c1cc7b7afdec2ef92912a8c350bc8 latest 5655450675ef 5 weeks ago 1.26 GB
8ee86f0a418d570a02bbfbcde2d16ecf54072a0a latest f80d8f997aaf 6 weeks ago 1.44 GB
8a1a87d17dc87caaeb3c750f44279236c4c9dbf8 latest 4b865e338520 6 weeks ago 1.16 GB
docker.io/opensuse/leap 15 1761e347bba2 6 weeks ago 102 MB
029cc87b07cf6d3eb3ed31cd8399cf5a75f78d44 latest 89a545cf55bb 6 weeks ago 1.33 GB
23e988910d11756b30b2351ab00b99d6395075b9 latest 89a545cf55bb 6 weeks ago 1.33 GB
7f97ea83f8bd099fa94144a6909d4ed45f8c8355 latest 89a545cf55bb 6 weeks ago 1.33 GB
81363c91d4914aeb42c5a97078cae6b00a48497c latest 89a545cf55bb 6 weeks ago 1.33 GB
b0aaaec144ae35f0ab8b2610b459e0983b55de7e latest 89a545cf55bb 6 weeks ago 1.33 GB
b3c4f64ba06b8d9891513a136443e88074b526ef latest 89a545cf55bb 6 weeks ago 1.33 GB
bc9fb02ac4faa8ce784b8355f421d209c7f978dc latest 89a545cf55bb 6 weeks ago 1.33 GB
8f7436b4c9798db556fdc0ccf5ae6faaff33b531 latest 14b28fbe0c52 6 weeks ago 1.31 GB
b52ff0640a918ce41958cc3c65d5d355fc6b19bb latest b5f5d35aca30 7 weeks ago 1.57 GB
bfa7b1bcb59d498ef077c89f48f804697d2c768e latest b5f5d35aca30 7 weeks ago 1.57 GB
24ac056b36c25e7c0a4b5b2bdd8da078b1c4eeb2 latest d4b5dcadc5e1 7 weeks ago 599 MB
54a2bac59f4587f0ebe19467a421d34ef460247b latest 89c532aee9cb 8 weeks ago 599 MB
8b56c3889c0e8cda511e79c41999085d9fe2f5e3 latest c92156f3e0f4 8 weeks ago 1.28 GB
e90d43a8659a298b45c5be4f39419d6a968957a4 latest e583267578e6 8 weeks ago 504 MB
f823e53dc7ef6c79143ed8ba15526e8955526e4b latest 0c01058cde89 2 months ago 1.77 GB
174e89aaa76f9ef7d339a1d773a0c78c787edb18 latest 6b9f78351a0c 2 months ago 1.16 GB
8bbaa11cef1bd4400c8a611a531f9a186881ab6f latest 6b9f78351a0c 2 months ago 1.16 GB
cb41d6e8740321105c263a19cd4987027635cfd2 latest 6b9f78351a0c 2 months ago 1.16 GB
212be2a9f5b57c6e93ddee9f3717b3c51890336f latest 469c19fad18a 2 months ago 1.54 GB
c53f9b58bb5a01c88b0b8a2c9002319baf61912d latest 469c19fad18a 2 months ago 1.54 GB
800a16822794950dc9166d17bbbc201da85df936 latest e0651c1932f6 2 months ago 1.41 GB
81154e260723c3be387a3a98bbeca82dc1473b80 latest e0651c1932f6 2 months ago 1.41 GB
955c8572b32ad705e2c64e121f1c941d7dc00ed9 latest e57001ef342a 2 months ago 1.28 GB
cfc7fc6fad121bcc5f7416069e5e1925a9d393b0 latest dd7a6150148a 2 months ago 1.28 GB
1cf2793f4965db2b78357498add59f22b4880b3d latest 5695e01b5287 2 months ago 1.56 GB
d2dd26d50473ba728600376945c35fe487cb65eb latest 5695e01b5287 2 months ago 1.56 GB
0f4525a1f878ed062d072cd4de794ee5af8335ac latest 5695e01b5287 2 months ago 1.56 GB
08437018300ebe8355f26d98435e6dc28439e6aa latest 18f2caa5927b 2 months ago 1.93 GB
347ccd0d34eeb6d7a98c0b29c3b191ba5786ec03 latest 431dec22ebca 2 months ago 1.93 GB
48c07934d34d5776e0b30534358d003daed89b9e latest c3c778ca15b8 2 months ago 1.73 GB
4f726bbaa49d990f65e2b32fa28b336e803c85e0 latest 50e10678c29a 2 months ago 1.38 GB
docker.io/ubuntu 18.04 cd6d8154f1e1 4 months ago 84.1 MB
docker.io/centos 7 5182e96772bf 5 months ago 200 MB
docker.io/opensuse leap 35057ab4ef08 9 months ago 110 MB
I don't know which of those images are the result of current {{Dockerfile}}s in my pipeline jobs and which are the result of previous iterations of {{Dockerfile}}s, Is there some way to determine this? How does the previously suggested docker-gc know which of the above are current and which are stale? The comment says # Find images that are created at least GRACE_PERIOD_SECONDS ago but creation date is nowhere near an indicator of whether an image is current or not. Some kind of last-used time would be, but Docker doesn't provide that. So lacking that functionality in Docker, I would submit that if Jenkins is creating the images and is naming them in an obfuscating way, Jenkins is responsible for cleaning up stale images. To that end, in the steps of a pipeline job that is running in a docker container, is the repository ID known? It's displayed in the output of a pipeline job:
+ docker inspect -f . f880bb025268313fbd2fa186d75498129f92b622
But is it available to, say, an sh command in a step of the job so that I can start to do my own tracking for proper garbage collection (which I would submit that docker-gc is not). |