Question: What is the best way to give a
task
the required access it needs for binding to privileged ports?
I am created a Nomad job
with a task
that needs to bind to the privileged ports 80
and 443
.
In the Nomad jobs list, the is reported as “running”.
When I view the task logs I see the following:
[WARN] Unable to listen: [listen tcp :443: bind: permission denied]
[WARN] Unable to listen: [listen tcp :80: bind: permission denied]
If I run sudo netstat -tunlp | grep 80
on the Nomad client it does not show any process using either port 80
or 443
.
My guess is that because the task is not being run as root
(the process owner shows nobody
), it does not have the permissions it needs to bind to those privileged ports.
Here is a minimal version of my job definition:
job "web-api" {
group "primary" {
count = 1
network {
port "http" {
static = 80
host_network = "public"
}
port "https" {
static = 443
host_network = "public"
}
}
service {
name = "web-api"
port = "http"
}
service {
name = "web-api"
port = "https"
}
task "main" {
driver = "exec"
config {
command = "${NOMAD_ALLOC_DIR}/web-api"
}
}
}
}