marathon命令运行docker compose up错误

57hvy0tb  于 2021-06-26  发布在  Mesos
关注(0)|答案(1)|浏览(345)

我在马拉松比赛中遇到了麻烦。有两种情况
docker-compose-up -d 在ubuntu命令界面中。
它成功地运行和部署了应用程序。
docker-compose-up -d 在json文件中

{
  "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":{}
    }
  ]
}

然后它就无法部署,马拉松比赛总是围绕着等待、延迟和跑步来改变状态。当我触摸 sudo ps -a 在服务器中,似乎容器正在不断地重新启动。

在梅索斯,同样的任务完成了很多次。

这是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"
j91ykkif

j91ykkif1#

要运行在marathons上使用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 或者分组参加马拉松比赛。
如果你仔细看,你会发现这不是一对一的翻译。在compose.yaml中,没有定义资源cpu/mem。另一个区别是端口Map。在mesos上运行服务时,不应该静态地分配端口。这就是为什么主机端口设置为0,所以随机端口将被分配。另一件重要的事情是健康检查。您应该为应用程序定义健康检查。最后是卷。在mesos上运行服务时,它们需要文件来持久化,您应该调查持久化卷。

相关问题