How to mount /var/run/docker.sock?

Hi @snesbittsea,

Would you be able to provide a sample job that caused that error?

I tried to reproduce it, but it all seems to work. Here’s a sample job that I created based on our Traefik guide:

job "traefik-demo" {
  datacenters = ["dc1"]

  group "lb" {
    count = 1

    network {
      port "http" {
        to     = 80
        static = 80
      }

      port "ui" {
        to     = 8080
        static = 8080
      }
    }

    task "traefik" {
      driver = "docker"

      config {
        image = "traefik:v2.3"
        args  = ["--api.insecure=true", "--providers.docker"]
        ports = ["http", "ui"]
        volumes = [
          "/var/run/docker.sock:/var/run/docker.sock"
        ]
      }
    }
  }

  group "demo" {
    count = 3

    network {
      port "http" {}
    }

    task "server" {
      driver = "docker"

      config {
        image = "hashicorp/demo-webapp-lb-guide"
        labels {
          traefik.http.routers.demo.rule                      = "PathPrefix(`/demo`)"
          traefik.http.services.demo.loadbalancer.server.port = "${NOMAD_PORT_http}"
        }
        ports = ["http"]
      }

      env {
        PORT    = "${NOMAD_PORT_http}"
        NODE_IP = "${NOMAD_IP_http}"
      }
    }
  }
}

Accessing http://localhost/demo will reach the different instances of the app:

$ curl http://10.0.2.15/demo
Welcome! You are on node 10.0.2.15:29672
$ curl http://10.0.2.15/demo
Welcome! You are on node 10.0.2.15:30195
$ curl http://10.0.2.15/demo
Welcome! You are on node 10.0.2.15:23164

One important piece is to enable mounting host paths in the Docker plugin configuration for your Nomad clients:

plugin "docker" {
  config {
    volumes {
      enabled = true
    }
  }
}