How to find container image name/ tag from inside the container

2.3k Views Asked by At

Apologies in advance if this is a bad question, but is it possible to look up the name and tag of the image off of which a container is running, from inside that container?

2

There are 2 best solutions below

3
On

As stated by Adrian Antunez, you can run this command to the the container id:

cat /proc/self/cgroup | head -n 1 | cut -d '/' -f3

But it seems you cannot find the image name/tag been used. It seems it's due to security matters.

0
On

This is not possible currently from (07-2022), and will not be implemented.

You can implement it for example with export IMAGE_NAME=iamawsome-V2.2.3, during build time, so you can use this env in the image.