In-use OCI images disappeared from `incus image ls`

Hi everyone,

I noticed that one of my OCI containers was outdated and used incus image ls to verify when its base image was last updated. Then I found out that its base image disappeared - incus image ls showed the OCI image of a different container created a few days ago but not this older one. I checked the instance configuration’s volatile.base_image and did an incus image info on the hash but it just gave me Image ... not found.

I thought that incus actually updates these OCI images that are being used via an alias (like eg.docker.io/postgres:18-alpine but if incus didn’t even keep the image, it surely isn’t updating it?

Please help me understand what is happening here, thanks in advance :slight_smile:

The local image server stores images for up to 10 days since last use.
Those images also auto-update during those 10 days, so the particular hash you have recorded on the container will quickly go away from the local cache.

Hi Stéphane, thank you for your response!

Okay what you describe is what I would expect too, depending on interpretation. Does “since last use” mean since last instance creation or since the last instance based on this image was running?

I would personally expect this behaviour:

  • instance is created based on image X v1
  • image X is updated to v2
  • image X v1 is still in use at this point (is this where I am wrong?)
  • instance is restarted
  • now image X v1 is not in use anymore, image X v2 is in use
  • image X v1 is deleted after 10 days (by default)
  • image X v2 is kept since it is in use and should appear in incus image ls

Where am I wrong here? Clearly there was some point in time where the image was considered not in use and deleted after a period of 10 days, but no newer version directly replaced it either. The scenario I find myself in seems like it should be impossible, since I have OCI instances running for which no image exists in incus image ls.

@unicorn From the Incus documentation:

Incus keeps track of the image usage by updating the last_used_at image property every time a new instance is spawned from the image.

So merely running a container based on an image does not make the image to be “used” from the viewpoint of the image cache.

Thank you @ykazakov!

I am wondering one last thing. Do I understand correctly that if I create an application container based on an OCI image with images.auto_update_cached: true, does the container pick up the updated image on restart if an update happens? And would that count as “spawning” a new instance from the image?

Thank you for your help, I didn’t quite understand the documentation here. :slight_smile:

No, once the container is created, its image is not “updated” upon restart. This is similar to docker containers. You can however “rebuild” the (stopped) container based on the (new) image using the incus rebuild command, which should count as the image “use” and should update the last_used_at flag for the image.

Note that rebuild will delete all data in the container that was created after the container has started, so it is essentially equivalent to deleting the container and creating it again, with exactly the same settings, from the new image. To use “stateless” OCI containers, you should, therefore, put any persistent data, such as configuration files, into a separate volume attached to the container (ideally with dependent: "true"), so that it does not get deleted upon rebuild.

Thank you for explaining!