我正在通过马拉松在mesos群集上部署2个docker应用程序。 一个组,包含一个子组,该子组包含2个应用程序(app,db)
APP依赖于数据库
我需要通过JSON文件将DB容器的动态分配的主机端口作为ENV变量提供给APP容器。然后,我可以在运行时使用shell脚本/连接到db等进行进一步的操作
如何在保持主机端口动态(即不将其固定在1521上)的同时做到这一点?
请参见下文(格式很抱歉)
{
"groups":[
{
"apps":[
{
"cpus":0.5,
"mem":2096,
"instances":1,
"container":{
"docker":{
"image":"NAME",
"type":"DOCKER",
"network":"BRIDGE",
"forcePullImage":true,
"portMappings":[
THIS DBPORT ===> {
"name":"DBPORT",
"hostPort":0,
"containerPort":1521,
"protocol":"tcp"
},
{
"hostPort":0,
"containerPort":9990,
"protocol":"tcp"
}
]
}
},
"fetch":[
{
"uri":"file:///etc/docker/docker.tar.gz",
}
],
"id":"/group1/subgroup1/database"
},
{
"cpus":0.5,
"mem":2096,
"instances":1,
"container":{
"docker":{
"image":"IMAGE",
"type":"DOCKER",
"network":"BRIDGE",
"forcePullImage":true,
"portMappings":[
{
"hostPort":0,
"containerPort":8080,
"protocol":"tcp"
},
{
"hostPort":0,
"containerPort":9990,
"protocol":"tcp"
}
]
}
},
"env":{
"ORACLE_HOST":"database.subgroup1.group1.marathon.mesos",
"ORACLE_PORT":"XXXXX", <=== PASS DBPORT HERE
"ORACLE_SID":"SID"