0

I am running a Cloud Run service on the Cloud Run emulator through VS Code. At some point, I need to access to data stored on a Firebase Storage local emulator (say localhost:9199). However, my Python code on Cloud Run is facing this issue:

<urllib3.connection.HTTPConnection object at 0x7f6d392af2e0>: Failed to establish a new connection: [Errno 111] Connection refused

Some investigations led me thinking that because Cloud Run emulator is running a virtual machine, it does not know about localhost:9199.

Referring to this answer here, is it possible to add -net host option to the docker internally used by Cloud Run? If not, any idea to solve this will be highly appreciated.

DCoder
  • 93
  • 6
  • Does [this](https://github.com/DataDog/docker-dd-agent/#tracing--apm) help to solve your issue? – Roopa M May 31 '23 at 14:02
  • Well not really. Because, I don't have direct access to Docker via the VS Code Cloud Run emulator. There is just a `launch.json` file that can be used to configure the virtual Cloud Run instance (example, specifying to use docker for building). But I couldn't find a doc specifying how to add options to `docker run`. Otherwise, I would be able to try the `-net host` option too. – DCoder May 31 '23 at 20:45

1 Answers1

1

Ok, it turned out to be simpler than I thought, but if it can save to someone a few hours, here is how I solved the issue:

I simply replaced localhost with host.docker.internal in the code running from within the docker container, and that was it. Credits go to this answer, where you will find more details based on your system config.

DCoder
  • 93
  • 6