Docker Community Forums

Share and learn in the Docker community.

R = requests.get('host') Error : Name or service not known

I am getting some wired error . I ran one python program to to get some response using requests.get(‘host’) and working fine while running locally on python, bit getting error Name or service not known while running python program in docker container (I use docker-compose to start my application).

Sample Code :

import requests
print("Validating connection host")
r = requests.get('http://hostname')
print(r)
print("Response after connection host") 

Initially [, I thought that issue is with host name but getting response if execute same program locally using pyCharm.

Any help will be highly appreciated.