I got a requirement recently to identify the details of the host in which the docker container runs. I searched a lot inside the container to find the trace of the host machine. I don’t have access to the docker server API. So I will not be able to query and get the details from there.

The only solution that I found was to configure a set of environment variables in the docker container that grabs the details of the host at the time of the deployment.
An example is given below. This will capture the hostname of the parent machine when we deploy the container.
docker run -itd -e HOSTNAME='hostname' image:tag
In the above example, the hostname is enclosed within backtick symbol. This will execute the command hostname on the host and assigns it to the environment variable HOSTNAME. This environment variable will be accessible from the docker container can be used for our purpose. Like this, we can pass any parameter dynamically at the runtime to the container.