Docker Community Forums

Share and learn in the Docker community.

Is there a way to get the image name or tags from a dockerfile?


(G) #1

Folks,

When I build a docker image with, is there a way for me to get the image name or tags from the dockerfile?
For example: Put a line in the docker file that gets the image name and/or tags and insert it as a new line in one of the files of my generated image (to be used as some identifier later).
If not possible, is there a way to get the image name from inside a running containers. Similar example, when a container starts put the image name/tags in a file inside the container to be used as some sort of identifier. .

Thanks

Golan


(Sam) #2

there is no direct way to get the info from INSIDE the container (the code doesn’t know its inside a container)
you CAN pass arguments to the container at startup and the startup CMD can put them whereeer you want.