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.
I have tried like the below
import os
os.system("hostname") # to get the hostname
os.system("hostname -i") # to get the host ip
Output:
2496c9ab2f4a172.*.*.*
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.