[help] Docker Container with static IP

Hello there,

I have a job running for my adguard deployment. It’s working great but I have minor problem: nomad is showing me the hosts IP instead of the static container IP I created for it - and it also registers this to consul.

My job file (condensed):

job "dns" {
   group "adguard" {
     count = 1

    service {
      tags = [ "dns", "adguard" ]
    }

    network {
      port "dnsserver" {
        static = 53
      }
      port "dot" {
        static = 853
      }
      port "bootpserver" {
        static = 67
      }
      port "http" {
        static = 80
      }
      port "https" {
        static = 443
      }
      port "admin" {
        static = 3000
      }
    }


    task "server" {
      driver = "docker"

      config {
        image = "adguard/adguardhome"
        ports = [
          "dnsserver",
          "bootpserver",
          "dot",
          "http",
          "https",
          "admin"
        ]
        network_mode = "staticip"
        ipv4_address = "192.168.0.2"
        dns_servers = [ "192.168.0.1" ]
      }
    }
  }
}

I understand why this is but is there a way to tell nomad and consul the “correct” ip?

Ok… I moved the service stanza in the task stanza and it now reports the static ip instead of the hosts ip correctly. BUT the checks are failing nonetheless…

Also nomad is still showing hosts ip.

job "dns" {
  migrate {
    max_parallel = 1
    health_check = "checks"
    min_healthy_time = "10s"
    healthy_deadline = "5m"
  }

  group "adguard" {
    count = 1

    task "server" {
      driver = "docker"

      service {
        name = "dns"
        port = "dns"
      }

      service {
        name = "adguard"
        port = "http"
        address_mode = "driver"

        tags = [ "http", "https" ]

        check {
          name         = "http"
          port         = "http"
          address_mode = "driver"
          type         = "http"
          protocol     = "http"
          path         = "/"
          interval     = "10s"
          timeout      = "2s"
        }
      }

      resources {
        cpu    = 200
        memory = 64
        network {
          port "http" {}
          port "https" {}
          port "dns" {}
          port "dot" {}
          port "bootp" {}
          port "admin" {}
        }
      }

      config {
        image = "adguard/adguardhome"
        interactive = true
        network_mode = "staticip"
        port_map {
          http  = 80
          https = 443
          dns   = 53
          dot   = 853
          bootp = 67
          admin = 3000
        }
        ipv4_address = "192.168.0.2"
        dns_servers = [ "192.168.0.1" ]
      }

    }
  }
}