无法访问使用Azure中的DCOS Marathon部署的helloworld App

时间:2018-02-28 10:26:54

标签: azure docker marathon dcos azure-container-service

我使用DCOS和Marathon Framework在Azure中部署了一个hello world应用程序。我正在尝试使用托管应用程序的fqn:portnumber访问它。我无法打开该应用程序

以下是我用过的json



{
  "id": "/dockercloud-hello-world",
  "cmd": null,
  "cpus": 0.1,
  "mem": 128,
  "disk": 0,
  "instances": 2,
  "acceptedResourceRoles": [
    "*"
  ],
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "dockercloud/hello-world",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 80,
          "hostPort": 0,
          "servicePort": 10000,
          "protocol": "tcp",
          "labels": {}
        }
      ],
      "privileged": false,
      "parameters": [],
      "forcePullImage": true
    }
  },
  "healthChecks": [
    {
      "gracePeriodSeconds": 10,
      "intervalSeconds": 2,
      "timeoutSeconds": 10,
      "maxConsecutiveFailures": 10,
      "portIndex": 0,
      "path": "/",
      "protocol": "HTTP",
      "ignoreHttp1xx": false
    }
  ],
  "portDefinitions": [
    {
      "port": 10000,
      "protocol": "tcp",
      "name": "default",
      "labels": {}
    }
  ]
}




我已为主nsg资源添加了NSG入站规则 我为master lb资源添加了NAT规则,允许端口为自定义

2 个答案:

答案 0 :(得分:1)

在您的示例中,host port为0,Azure将在随机端口上侦听您的服务。您需要在NSG和lb上打开端口。

我建议您指定端口,您可以查看以下示例:

{
  "id": "/dockercloud-hello-world",
  "cmd": null,
  "cpus": 0.1,
  "mem": 32,
  "disk": 0,
  "instances": 1,
  "acceptedResourceRoles": [
    "slave_public"
  ],
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "dockercloud/hello-world",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 80,
          "hostPort": 80,
          "protocol": "tcp",
          "labels": {},
          "name": "test80"
        }
      ],
      "privileged": false,
      "parameters": [],
      "forcePullImage": true
    }
  },
  "healthChecks": [
    {
      "gracePeriodSeconds": 10,
      "intervalSeconds": 2,
      "timeoutSeconds": 10,
      "maxConsecutiveFailures": 10,
      "portIndex": 0,
      "path": "/",
      "protocol": "MESOS_HTTP",
      "ignoreHttp1xx": false
    }
  ],
  "requirePorts": true
}

注意:您应将acceptedResourceRoles设为slave_public。有关此问题的详细信息,请查看此link

答案 1 :(得分:1)

除了上面提到的JSON之外,我还需要使用代理URL来访问应用程序。我错过了那个