Listing exact image name/fingerprint

I’m trying to find out if the exact image alias or a fingerprint exists, but lxc image list does not support regexps, so I can’t do the same as for the container, i.e. lxc ls name$

I could parse JSON output, but seems a bit of an overkill, does it make sense to add a regexp option to image list command or is there some more obvious way that I’m missing?

Hi @Aleks, is there a specific reason for having a regex?

You can run lxc image list {fingerprint} which will return an empty list if there is no image matching this exact fingerprint. The same applies for lxc image show {fingerprint} and lxc image info {fingerprint}.

yeah, but that does not work with aliases, if I have an alias that is at the same time part of another alias, I have no way of checking if the alias exists, or do I?

For example, how do i get a fingerprint of just 2e-centos8, but not 2e-centos8-numbers without resorting to parsing json?

~$ lxc image list 2e-centos8  -c Lf
|          ALIASES           | FINGERPRINT  |
| 2e-centos8                 | bce676ce5216 |
| 2e-centos8-20230705T131928 | 3b984403fb8e |
| c8                         |              |

You can run lxc image info {alias} which will return the requested image including the fingerprint or an error if it doesn’t exist.

However having regex filter capabilities also on the image alias when using lxc image list might be helpful. Feel free to open up a feature request on GitHub.

ah lxc image info, I knew I was missing something obvious :wink:

this is good enough for me, but if anyone sees any utility into having regexps in lxc image list, I’ll be happy to open a feature request

1 Like