我在Marathon中遇到了一个问题。有两种情况
在Ubuntu命令界面中运行docker-compose-up -d
。
它成功运行并部署应用程序。
在Marathon Json文件中运行docker-compose-up -d
{
"id":"/piggy-demo-beta",
"cmd":"cd /home/ubuntu/spring-demo2 && sudo docker-compose up -d ",
"cpus":1,
"mem":4200,
"disk":0,
"instances":1,
"acceptedResourceRoles":[
"slave_public"
],
"portDefinitions":[
{
"port":10000,
"protocol":"tcp",
"labels":{}
}
]
}
然后它无法部署并且Marathon总是在等待,延迟和运行周围改变状态。
当我触摸服务器中的sudo ps -a
时,似乎容器不断重启。
在Mesos中,同样的任务完成了很多次。
这是compose.yml文件。
version: '2'
services:
rabbitmq:
image: rabbitmq:3-management
restart: always
ports:
- 15672:15672
logging:
options:
max-size: "10m"
max-file: "10"
config:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
image: sqshq/piggymetrics-config
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
registry:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
image: sqshq/piggymetrics-registry
restart: always
ports:
- 8761:8761
logging:
options:
max-size: "10m"
max-file: "10"
gateway:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
image: sqshq/piggymetrics-gateway
restart: always
ports:
- 80:4000
logging:
options:
max-size: "10m"
max-file: "10"
auth-service:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
NOTIFICATION_SERVICE_PASSWORD: $NOTIFICATION_SERVICE_PASSWORD
STATISTICS_SERVICE_PASSWORD: $STATISTICS_SERVICE_PASSWORD
ACCOUNT_SERVICE_PASSWORD: $ACCOUNT_SERVICE_PASSWORD
MONGODB_PASSWORD: $MONGODB_PASSWORD
image: sqshq/piggymetrics-auth-service
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
auth-mongodb:
environment:
MONGODB_PASSWORD: $MONGODB_PASSWORD
image: sqshq/piggymetrics-mongodb
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
account-service:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
ACCOUNT_SERVICE_PASSWORD: $ACCOUNT_SERVICE_PASSWORD
MONGODB_PASSWORD: $MONGODB_PASSWORD
image: sqshq/piggymetrics-account-service
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
account-mongodb:
environment:
INIT_DUMP: account-service-dump.js
MONGODB_PASSWORD: $MONGODB_PASSWORD
image: sqshq/piggymetrics-mongodb
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
statistics-service:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
MONGODB_PASSWORD: $MONGODB_PASSWORD
STATISTICS_SERVICE_PASSWORD: $STATISTICS_SERVICE_PASSWORD
image: sqshq/piggymetrics-statistics-service
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
statistics-mongodb:
environment:
MONGODB_PASSWORD: $MONGODB_PASSWORD
image: sqshq/piggymetrics-mongodb
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
notification-service:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
MONGODB_PASSWORD: $MONGODB_PASSWORD
NOTIFICATION_SERVICE_PASSWORD: $NOTIFICATION_SERVICE_PASSWORD
image: sqshq/piggymetrics-notification-service
restart: always
logging:
options:
max-size: "10m"
max-file: "10"
notification-mongodb:
image: sqshq/piggymetrics-mongodb
restart: always
environment:
MONGODB_PASSWORD: $MONGODB_PASSWORD
logging:
options:
max-size: "10m"
max-file: "10"
monitoring:
environment:
CONFIG_SERVICE_PASSWORD: $CONFIG_SERVICE_PASSWORD
image: sqshq/piggymetrics-monitoring
restart: always
ports:
- 9000:8080
- 8989:8989
logging:
options:
max-size: "10m"
max-file: "10"
答案 0 :(得分:1)
要在Marathon上运行使用docker compose设置的应用程序组,您应该将每个服务转换为Marathons应用程序。 来自compose.yaml的每个文件都在Marathon应用程序中具有相同的功能。
示例强>
让我们假设我们想运行一个名为piggy
的大型应用程序,它是从许多小型服务构建的。一项服务定义为
rabbitmq:
image: rabbitmq:3-management
restart: always
ports:
- 15672:15672
logging:
options:
max-size: "10m"
max-file: "10"
将导致
{
"id":"piggy/rabbitmq",
"container":{
"docker":{
"image":"rabbitmq:3-management",
"network":"BRIDGE",
"portMappings":[{
"containerPort":8761,
"hostPort":0
}],
"parameters":[
{
"key":"max-size",
"value":"10,"
},
{
"key":"max-file",
"value":"10"
}
]
},
"type":"DOCKER"
},
"cpus":1.0,
"mem":512.0,
"instances":1
}
需要对compose.yaml中定义的每个服务重复此过程。准备好的JSON应该是POST /v2/apps
或在Marathon group中组合在一起。
如果你近距离观察,你可以看到它不是1对1的翻译。在compose.yaml中没有定义资源cpus / mem。端口映射的另一个区别。当您在Mesos上运行服务时,您不应该静态分配端口。这就是主机端口设置为0的原因,因此将分配随机端口。另一件重要的事情是健康检查。您应该为您的应用程序定义运行状况检查。最后是卷。在Mesos上运行服务并且需要文件持续时,您应该调查persistent volumes。