🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
How to access services running on your machine from your broker running in Docker
Do you need to access your local machine's network from inside your broker running on Docker?
For instance, I wanted to create a REST endpoint so I could send some data from an RDP in a broker running in Docker. The problem is that you can't use localhost
or 127.0.0.1
For example, if I start my REST endpoint at port 9010 on my local machine, I can do telnet localhost 9010
And everything works fine.
However, from a Docker container (in this case an Ubunutu image), life is not so good:container# telnet localhost 9010
Trying 127.0.0.1...
Trying ::1...
telnet: Unable to connect to remote host: Cannot assign requested address
That's because localhost
is local to the container.
So I need to identifiy the local machine's network to the container. It's pretty simple, instead of using localhost short cuts, just specify your machine's IP address:
host# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.28.138.196 netmask 255.255.240.0 broadcast 172.28.143.255
...
container# telnet 172.28.138.196 9010
Trying 172.28.138.196...
Connected to 172.28.138.196.
So now I can just set my RDP Rest Consumer to send to 172.28.138.196.