Back

[SOLVED] Python Docker Container Host File

  • 0
  • Functions
EthanJames
19 Jun, 2023, 16:45

Hello! How can I have the docker run command add in an additional host-name when I execute a new function? At the moment I have the machine host file working correctly but when I run a new function the host file for that new machine that is created is missing the host file so the connection times out. Any ideas on how I can fix this so when I execute a function it can connect to the correct address?

TL;DR
The user was having issues with Docker containers not being able to resolve host names when running new functions. They tried configuring the host file on the host machine, but the host file for the new machine created by Docker was missing. The solution was to add the host names to the outbound of the VM to the internet, allowing the use of URLs without having them in the host names. The user provided an example of how to use the client to connect to Appwrite.
EthanJames
19 Jun, 2023, 16:47

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='###', port=443): Max retries exceeded with url: /api/Identity/Token (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f4fff706a90>: Failed to resolve '###' ([Errno -2] Name does not resolve)"))

Drake
19 Jun, 2023, 20:26

You can't really...but do you have the host configured in your host machines host file?

EthanJames
19 Jun, 2023, 23:48

correct configured in the host file but it cant resolve the name from the function

Drake
19 Jun, 2023, 23:50

are you on windows or unix?

EthanJames
20 Jun, 2023, 00:40

unix

Drake
20 Jun, 2023, 01:23

I thought the hosts file on the host machine is automatically passed to docker containers.

Otherwise, I don't think there's any other option

Binyamin
20 Jun, 2023, 01:34

Are you trying to connect to your Appwrite from a function internally? If this is your use-case there is some workaround Like B: 👇

Binyamin
20 Jun, 2023, 01:35

So you can use your client like such for example

TypeScript
client = Client()
    .set_endpoint('http://1.1.1.1/v1') 
EthanJames
20 Jun, 2023, 06:33

We were able to add the host names on the outbound of the VM to the internet and this allowed us to use the URLs without having them in the host names. Thank you for your support!

EthanJames
20 Jun, 2023, 06:34

[SOLVED] Python Docker Container Host File

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more