I know it is possible to access the docker api and the following command works just fine:
curl -s --unix-socket /var/run/docker.sock http:/v1.24/containers/$HOSTNAME/json | jq -r '.Image'
However, I would really like avoid exposing the docker.sock
to the container itself because it is part of a CI build. Is there any other way of retrieving the container image id / hash (i.e. 2acdef41a0c
) from within a container itself without exposing the docker.sock
and making a curl
request to it?
Maybe something like what's shown here Docker, how to get container information from within the container ?