Pankaj Saha
Pankaj Saha

Reputation: 21

how docker containers can communicate in a Mesos/Marathon setup

I have created two docker containers for Apache Airavata. Let's say they are container A nad B. Container B is dependent upon container A. after starting container A, I have to provide the A's IP address as an environment variable to container B. Now container B's start up script will make changes in configuration file for container B. After this changes container B can communicate with container A.

when I was doing the setup in a local docker environment I manually created the containers and passed the required values during container creation.

docker run -i -d --name pga --env SERVER_HOST=172.17.1.84 --env SERVER_PORT=8930 -p 8787:80 -t pga:test

In a Mesos/marathon environment docker can be created in any Mesos slave system. Now how can I make the communication happened between containers? I am launching docker jobs with marathon framework.

Upvotes: 1

Views: 652

Answers (2)

hd.deman
hd.deman

Reputation: 1306

I recommend to you to try consul for service discovery. Also since you use Mesos/Marathon it may be useful to try Apollo, which also based on consul.

Upvotes: 1

hartem
hartem

Reputation: 411

The problem that you described can be solved by using a service discovery mechanism (such as Mesos DNS or Marathon Event Bus) in conjunction with some custom tooling (i.e. a script developed by you). Basically you need to write a script that runs inside container B and uses service discovery to find out container A's IP address, modifies the configuration file, and possibly restarts the service.

Upvotes: 1

Related Questions