Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

cannot access nomad docker task via local ip:port

with following job config. curl NOMAD_IP_http:NOMAD_PORT_http cannot access http-echo service.

there is no listenig port on localhost for incomming request.

why and how to access the http-echo service


job "job" {
  datacenters = ["dc1"]
  group "group" {
    count = 2
    network {        
      port "http" {}
    }
    service {
      name = "http-echo"
      port = "http"
      tags = [
        "http-echo",
      ]
      check {
        type      = "http"
        path      = "/health"
        interval  = "30s"
        timeout   = "2s"
      }
    }
    task "task" {
      driver = "docker"
      config {
        image = "hashicorp/http-echo:latest"
        args = [
          "-listen", ":${NOMAD_PORT_http}",
          "-text", "Hello and welcome to ${NOMAD_IP_http} running on port ${NOMAD_PORT_http}",
        ]
      }
      resources {}
    }
  }
}

UPDATE

after config driver network_mode, curl successfully.

network_mode = "host"

question from:https://stackoverflow.com/questions/65559797/cannot-access-nomad-docker-task-via-local-ipport

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...