Error on trivial docker job syntax: No argument or block type is named "ports"

I’m able to run docker without port mapping, but this is the first time I’m trying to get port mapping working… If I remove the ports label, it passes the syntax check. Any ideas how to fix this? Thanks

2020-08-19T08:47:14-05:00 Failed Validation 2 errors occurred:
* failed to parse config:
* Invalid label: No argument or block type is named “ports”.

For the network->port arg, I’ve also tried ‘static’ instead of ‘to’ with the same results…

job…
group “influx_runner” {

network {
   port "influxdb" {
     to = 8086
   }
}

task "influx_db" {
  driver = "docker"

  config {
    image   = "influxdb"
    ports = ["influxdb", ]  #- also tried without the comma, but docs have the comma
  }

}

Also the job file passes ‘nomad job plan’…

Here is the full job output:

$ nomad alloc status 41b66252
ID = 41b66252-8b3c-29d9-3a61-dd4cc7edf7a9
Eval ID = 1c7ac6ba
Name = influx_dev.influx_runner[0]
Node ID = cd444b89
Node Name = XXXYYY
Job ID = influx_dev
Job Version = 15
Client Status = failed
Client Description = Failed tasks
Desired Status = run
Desired Description =
Created = 24s ago
Modified = 20s ago
Deployment ID = aae536b9
Deployment Health = unhealthy
Reschedule Eligibility = 15m36s from now

Allocation Addresses
Label Dynamic Address
influxdb yes 10.13.12.125:23151 -> 8086

Task “influx_db” is “dead”
Task Resources
CPU Memory Disk Addresses
100 MHz 300 MiB 300 MiB

Task Events:
Started At = N/A
Finished At = 2020-08-19T14:03:26Z
Total Restarts = 0
Last Restart = N/A

Recent Events:
Time Type Description
2020-08-19T09:03:28-05:00 Killing Sent interrupt. Waiting 5s before force killing
2020-08-19T09:03:26-05:00 Alloc Unhealthy Unhealthy because of failed task
2020-08-19T09:03:26-05:00 Not Restarting Error was unrecoverable
2020-08-19T09:03:26-05:00 Failed Validation 2 errors occurred:
* failed to parse config:
* Invalid label: No argument or block type is named “ports”.
2020-08-19T09:03:26-05:00 Task Setup Building Task Directory
2020-08-19T09:03:26-05:00 Received Task received by client

$ nomad version
Nomad v0.11.0 (5f8fe0afc894d254e4d3baaeaee1c7a70a44fdc6)

This might be the root of my problem

Same problem here.

$nomad version
Nomad v1.0.2 (4c1d4fc6a5823ebc8c3e748daec7b4fda3f11037)

Ok, after having tried to resolve this for 2 hours, I made this post.
2 minutes later, I restarted the nomad clients on my machines thinking it might not have restarted them after upgrade.

Tada, all works. Sorry for resurrecting this thread for nothing.

I’m running into a similar issue, where on the first nomad job run I receive

  • failed to parse config:
  • Invalid label: No argument or block type is named “ports”.

This particular job has a count of 2. 1 does eventually come up successfully but the other task keeps failing with the above error.

This is on nomad v1.1.6

job “my_job” {
datacenters = [“dc1”, “dc2”]
spread {
attribute = “${node.unique.id}”
}
type = “service”
priority = 70
update {
stagger = “30s”
max_parallel = 1
}
group “my_job” {
count = 2
network {
port “my_job” {
to = 5000
}
}
constraint {
operator = “distinct_hosts”
value = “true”
}
restart {
attempts = 5
delay = “30s”
interval = “30m”
mode = “delay”
}
reschedule {
delay = “30s”
delay_function = “fibonacci”
max_delay = “10m”
interval = “24h”
attempts = 10
unlimited = false
}
task “my_job” {
driver = “docker”
config {
ports = [“my_job”]
service {
port = “my_job”
name = “my_job”
tags = [“nginx”]
check {
type = “http”
port = “my_job”
path = “ping”
interval = “30s”
timeout = “3s”
}
}
resources {
cpu = “200”
memory = “100”
memory_max = “1000”
}
}
}
}