So I am working on creating a docker container
for a camel
project. In the project I am sending data to a messaging queue using apache karaf
.
Now when the project is ran normally, ie without as a container , it works properly. The karaf broker url
is - tcp://localhost:61616
. This value is coming from a config file inside the camel project.
But when I create the container
error is thrown -
Cannot connect to the broker url - tcp://localhost:61616
My guess is 'localhost' inside the docker
wouldn't be considered the localhost
of my machine (laptop) . Inside the container
, locahost
would be it's own IP address, I believe.
So, what address should I put for the broker url? 127.0.0.1? or my laptop's external IP?
If you camle project is running as docker container and karaf on host then you need to connect to karaf using host ip address. You can change broker url in config like below
tcp://host_ip:61616
As docker container is also like a vm and it has its own network and isolated form host, so localhost for host and container is different.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.