I currently build my images and tag them with the commit hash. I then pull this image and run it (either via the commit hash or the latest tag). How can I find out the commit hash from a running container ?
All I currently know is the container hostname. So if the container is running I can get the digest:
docker inspect --format='{{.Config.Image}}' hostname
Then from the digest I can search on Dockerhub to find the tag linked to the digest (not sure how to do it) and then the tag has the commit hash linked to it.
Unfortunately, if the container is not still active I get the error:
Error: No such object: hostname
Is there any other way to do this?