我只是整理了一个小 Nomad 工作来展示这个工作,所以你可能会有一个轻微的配置错误。为了让您自己运行这项工作,我在此处将其作为要点提供。同样,我有一个 nginx.conf,它让 nginx 在 Nomad 作业文件中的任何端口上侦听。
这是 Nomad 的工作:
job "nginx" {
datacenters = ["dc1"]
type = "service"
group "cache" {
count = 1
task "redis" {
driver = "docker"
config {
image = "nginx:1.11.10"
volumes = ["new/default.conf:/etc/nginx/conf.d/default.conf" ]
network_mode = "host"
}
artifact {
source = "https://gist.githubusercontent.com/dadgar/2dcf68ab5c49f7a36dcfe74171ca7936/raw/c287c16dbc9ddc16b18fa5c65a37ff25d2e0e667/nginx.conf"
}
template {
source = "local/nginx.conf"
destination = "new/default.conf"
change_mode = "restart"
}
resources {
network {
mbits = 10
port "nginx" {
static = 8080
}
}
}
}
}
}
然后我可以查询该地址并查看 nginx 绑定到该端口,因此正在安装的模板正常工作。
$ curl http://127.0.0.1:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
如果你看一下要点,我也会展示正在渲染和正确安装的文件。
希望这对你有帮助!还请务必查看社区页面以获取帮助。我们有一个 Gitter 房间和一个邮件列表。