Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k 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 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...