How to map the port with 0.0.0.0:8080 instead of default mapping 127.0.0.1:8080

Hi,
Port is mapped with 127.0.0.1 instead of 0.0.0.0 as below while running the container, so that application is unable to access from browser.
What configuration is required to map 0.0.0.0 instead of 127.0.0.1.

127.0.0.1:8085->38085/tcp, 127.0.0.1:8085->38085/udp, 127.0.0.1:1521->51126/tcp, 127.0.0.1:1521->51126/udp, 127.0.0.1:22->51127/tcp, 127.0.0.1:22->51127/udp
Thanks.

See Binding ports to 0.0.0.0 · Issue #12106 · hashicorp/nomad · GitHub , Nomad can’t use 0.0.0.0. But it is anyway odd that Nomad is choosing 127.0.0.1 instead of some external ip address. Check default network in your client configuration.

Hi,

0.0.0.0 is binding by default if run as docker container as below

f77b6ebfd5b0 get.rnd.metricstream.com/fresh/cicd/certified/base:20230210184245 “/opt/recipe-centos/…” 3 days ago Up 10 seconds 0.0.0.0:51127->22/tcp, :::51127->22/tcp, 0.0.0.0:51126->1521/tcp, :::51126->1521/tcp, 0.0.0.0:38085->8085/tcp, :::38085->8085/tcp, 0.0.0.0:49160->8111/tcp, :::49160->8111/tcp, 0.0.0.0:49159->8161/tcp, :::49159->8161/tcp, 0.0.0.0:49158->8222/tcp, :::49158->8222/tcp, 0.0.0.0:49157->27017/tcp, :::49157->27017/tcp plab

127.0.0.1 is binding by default if run as nomad job as below. We are running singe node cluster.

d4f3eddada5b get.rnd.metricstream.com/fresh/cicd/certified/base:20230210184245 “/opt/recipe-centos/…” 10 seconds ago Up 8 seconds 22/tcp, 1521/tcp, 8085/tcp, 8111/tcp, 8161/tcp, 8222/tcp, 27017/tcp, 127.0.0.1:8085->38085/tcp, 127.0.0.1:8085->38085/udp, 127.0.0.1:1521->51126/tcp, 127.0.0.1:1521->51126/udp, 127.0.0.1:22->51127/tcp, 127.0.0.1:22->51127/udp ms-instance-task-7755b36c-bb94-cc44-cb19-da26aaea02d1

We are not familiar on nomad. We just started learning. From where the 127.0.0.1 (localhost) is picking in the nomad job. It could be helpful if you point out the right file to check the same.

@grvenkatesan can you post your nomad configuration and your job configuration?

Hi,

Find the below nomad and job configuration. By default allocation address bind with 127.0.0.1 instead of ip address. I observed that it is happening in ubuntu OS only and the same is working in the Amazon Linux OS.

Allocation Addresses (mode = “bridge”):
Label Dynamic Address
*http yes 127.0.0.1:80

nomad.hcl

data_dir = “/opt/nomad/data”
bind_addr = “0.0.0.0”

advertise {

Defaults to the first private IP address.

http = “10.100.1.89” # must be reachable by Nomad CLI clients
rpc = “10.100.1.89” # must be reachable by Nomad client nodes
serf = “10.100.1.89” # must be reachable by Nomad server nodes
}

server {

license_path is required as of Nomad v1.1.1+

#license_path = “/opt/nomad/license.hclic”
enabled = true
bootstrap_expect = 1
}

client {
enabled = true
servers = [“0.0.0.0”]

}

nginx.nomad

job “nginx” {
datacenters = [“dc1”]
type = “service”
group “nginx” {
count = 1 # number of instances

network {
  mode = "bridge"
  port "http" {
    static = 80
  }
}

task "nginx-task" {
  driver = "docker"

  config {
    image = "nginx:1.23"
    force_pull = false
    auth_soft_fail = true

    ports = [
      "http"
    ]

  }

}

}
}