title: Get the host name from within the docker container from Python program
body: <p>As per my application requirement, I need to get the server IP and the server name from the python program. But my application is resides inside the specific docker container on top of the Ubuntu.</p>
  
  <p>I have tried like the below</p>
  
  <pre><code>import os
  os.system("hostname")  # to get the hostname
  os.system("hostname -i") # to get the host ip 
  </code></pre>
  
  <p>Output:
  <code>2496c9ab2f4a172.*.*.*</code></p>
  
  <p>But it is giving the host name as a it's residing docker containerid and the host_ip as it's private ip address as above. I need the hostname as it is the server name. But when I type these above commands in the terminal I am able to get result what I want. </p>