Unused image removal?

Are there any reasons why I shouldn’t remove images for old versions of updated apps, marked as ‘Unused’ in Portainer?

TIA

(TrueNAS Scale 25.10.2.1)

Only reason would be faster redeploy in case you have to roll back, for whatever reason

1 Like

Same question with volumes; I’ve got 154 of them, and all but 9 are marked ‘Unused’.

Same answer

Are those named ones, or anonymous (a lot of hex characters)? If the latter, you probably have an image somewhere specifying VOLUME in its Dockerfile, but are not mounting one when creating a container from it. In that case docker creates a new anonymous volume each time you (re-)create that container.

Anonymous; lots of characters. I’ve deleted them all.

Why would (does) an image specify a volume, but then not mount it?

By “(re-)create container”, would that be done each time I edit an app, e.g. to add more storage definitions?

After modifying the File Browser app, to add more storage, I found that four volumes had been marked as ‘Unused’, and four new, replacement, volumes had been created.

VOLUME is a kind of contract between the creator of the image and its users, so both sides should agree. Mounting a volume to a directory specified with VOLUME differs from a mount to a random directory in that if an empty volume is mount to a non-empty VOLUME directory, the content of the latter is copied to the volume first.

In my environment it was most often some directory with configuration files that whoever created the docker compose file (often me :slight_smile: ) did not even know it existed and so did not mount anything over it. Sometimes the creator of the image forgets to mention it in the documentation. Sometimes the image is updated adding a new VOLUME. Sometimes it is a plain user error (a typo in the destination etc, so you think that your database is persisted where you specified it but in fact it is in that anonymous volume). In short, it happens, and it is a good idea to inspect the content of the leftover anonymous volume to find out, where it is coming from.

I don’t use the TrueNAS apps (I am using docker compose directly), so I cannot comment what does and what does not for sure, but anytime something related to the container instance changes, including the image itself, environment, exposed ports, …, yes.

1 Like