nomad的配置文件语法使用的是hashicorp自己开发的dsl,详细语法: GitHub - hashicorp/hcl: HCL is the HashiCorp configuration language.

下面是一个配置文件的介绍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
job "hello1" {
  datacenters = ["dc1"]  #定义数据中心

  group "hello2" {      #组名字
    task "hello3" {      #一般使用服务名字表示task名字
      driver = "docker"     #使用docker驱动

      config {
        image = "hashicorp/http-echo"    #服务镜像名字
        args = [                                        #容器运行时的命令参数
          "-listen", ":5678",
          "-text", "hello world",
        ]
      }

      resources {                                #配置服务的资源
        network {
          mbits = 10                            #限制10MB带宽
          port "http" {
            static = "5678"                    #使用静态端口
          }
        }
      }
    }
  }
}