Map (running) container to existing images

Hi folks o/~

i’m trying to map a container from api.GetConatiners() an image from api.GetImages(). However, there seems to be zero correlation. Because the CRI needs (wants) that
There are, however, a few red herrings, which is why it took me so long to finally put this question up:

  1. api.Container.Config.Properties["volatile.base_image"] looks like the api.Image.Fingerprint but has a different value (i assume it is the fingerprint after the template has been applied to it?)
  2. api.GetContainerMetadata() returns api.ImageMetadata, takes roughly forever[1] — and again, returns no fingerprint which could be used to map the image

Perhaps i’m doing something wrong.
Please enlighten me!

1: on my laptop, with lxd (installed from snap) with 5 containers (2 running) and 4 images - with ZFS storage backend — in case that makes a difference

stgraber@castiana:~$ lxc launch ubuntu:16.04 c1
Creating c1
Starting c1
stgraber@castiana:~$ lxc config show c1
architecture: x86_64
  image.architecture: amd64
  image.description: ubuntu 16.04 LTS amd64 (release) (20180323)
  image.label: release
  image.os: ubuntu
  image.release: xenial
  image.serial: "20180323"
  image.version: "16.04"
  volatile.base_image: 1974758a1652b997e575f240d6762a920bda269c803402722b1ffa7f5274e3ff
  volatile.eth0.hwaddr: 00:16:3e:2d:39:51
  volatile.idmap.base: "0" '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.power: RUNNING
devices: {}
ephemeral: false
- default
stateful: false
description: ""
stgraber@castiana:~$ lxc image show 1974758a1652b997e575f240d6762a920bda269c803402722b1ffa7f5274e3ff
auto_update: true
  architecture: amd64
  description: ubuntu 16.04 LTS amd64 (release) (20180323)
  label: release
  os: ubuntu
  release: xenial
  serial: "20180323"
  version: "16.04"
public: false

There is however no guarantee that the image will be kept around. They get replaced as newer versions are available and so will go away from your cache and the remote server a few days down the line.

i had entirely forgotten about this property!