I want to connect two containers with each other ... I start with the creation of an overlay-network mynet
:
docker network create -d overlay mynet
After that, I´ve created the first service activemq
:
docker service create --name activemq -p 61616:61616 -p 8161:8161 --replicas 1 --network mynet rmohr/activemq
This starts and works perfectly fine, I also can access the WebUI http://localhost:8161/admin/
Now I want to start my serviceTimeService I have the following settings in the container:
docker service create --name timeservice -p 7000:7000 --replicas 1 --network mynet ni920/timeserviceplain:latest
java.naming.provider.url=tcp://localhost:61616
java.naming.user=admin
java.naming.password=admin
io.jexxa.rest.host=0.0.0.0
io.jexxa.rest.port=7000
So it should connect via tcp://localhost:61616
with the ActiveMQ
but it doesn't.
Do you guys have any clue what I should try by the way the communication works perfectly in a none Swarm
environment or in a Kubernetes-Pod
?
If you want your containers to communicate witch each other, you can use their names then let network driver resolves their ips.
Here is the network driver summary from docker docs:
- User-defined bridge networks are best when you need multiple containers to communicate on the same Docker host.
- Host networks are best when the network stack should not be isolated from the Docker host, but you want other aspects of the container to be isolated.
- Overlay networks are best when you need containers running on different Docker hosts to communicate, or when multiple applications work together using swarm services.
- Macvlan networks are best when you are migrating from a VM setup or need your containers to look like physical hosts on your network, each with a unique MAC address.
- Third-party network plugins allow you to integrate Docker with specialized network stacks.
In your case, replace localhost with service name activemq .
java.naming.provider.url=tcp://activemq:61616
.
.
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.