0

I am trying to subscribe to a topic running in a pubsub emulator running on my host machine.

I start up the emulator and it starts on port 8085.

Then I start the container using a docker-compose.yaml I set the environment variables:

environment:
  - PUBSUB_EMULATOR_HOST=0.0.0.0:8085
  - PUBSUB_PROJECT_ID=fake-project

And forward the ports in composer

ports:
  - 8085:8085

However, it then returns the following warning. That it cannot bind to the port because the emulator is already in use...

ERROR: for docker_kubernetes_1 Cannot start service kubernetes: driver failed programming external connectivity on endpoint docker_kubernetes_1 (a375f802e40946c8e724bbba91e159b5fe1ae268ff316b01f909465330ee8a88): Error starting userland proxy: listen tcp 0.0.0.0:8085: bind: address already in use

ERROR: for kubernetes Cannot start service kubernetes: driver failed programming external connectivity on endpoint docker_kubernetes_1 (a375f802e40946c8e724bbba91e159b5fe1ae268ff316b01f909465330ee8a88): Error starting userland proxy: listen tcp 0.0.0.0:8085: bind: address already in use ERROR: Encountered errors while bringing up the project.

I am new to container networking. I have tried with localhost, dockerhost, setting network:host.

I am aware there are pubsub emulators docker images, but ideally I'd like to run it on my host machine as it gives me more flexibility with how I am using the emualtor.

Thanks!

jmarlow
  • 176
  • 2
  • 6
  • `ports:` accepts inbound connections _into_ your container; you don't need it for outbound connections. Does the setup in [From inside of a Docker container, how do I connect to the localhost of the machine?](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) help you? – David Maze Jul 29 '20 at 12:45
  • I have tried what is suggested in that post. I am working on a linux VM in virtual box. I set the network tag in compose to "host" and environment variable PUBSUB_EMULATOR_HOST=127.0.0.1:8085. I no longer get the bind error, but it doesn't seem to receive the messages published to the emulator. – jmarlow Jul 29 '20 at 13:14

0 Answers0