docker-gen icon indicating copy to clipboard operation
docker-gen copied to clipboard

"Addresses" is empty even when "Networks" is not (upstream appears empty)

Open joaocc opened this issue 9 years ago • 2 comments

I have been having some problems in getting the nginx-proxy container to work properly. Basically, the "upstream" part of the template appears empty. After some troubleshooting it seems that the problem may be with docker-gen...

Versions:

  • Docker host: (Ubuntu 16.04)
  • Docker: (1.11.2, build b9f10c9)
  • Docker-compose: (1.7.1)

TLDR: the Addresses array is empty (os incomplete) even if Networks array is not.

To test this, I have generated a debug template that only outputs things to be inspected:

{{ json $ }}

Below are the 2 docker-compose files I used. The containers are either "dummy" ones (echo, whiami, ping), nginx-proxy and a docker-gen one.

xcommon/docker-compose.yml


---
version: "2"
networks:
  ci:
    driver: bridge
  pubnet:
    driver: bridge
services:
  whoami:
    image: jwilder/whoami
    restart: unless-stopped
    ports:
      - "8999:8000"
    environment:
      - VIRTUAL_HOST=whoami.xcommon.localy
  dockergen_dumpall:
    build: ./src/dockergen-dumpall
    networks:
      - default
      - pubnet
      - ci
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

xrproxy/docker-compose.yml


---
version: "2"
networks:
  pubnet:
    external:
      name: xcommon_pubnet
  ci:
    external:
      name: xcommon_ci
services:
  ping:
    image: dockercloud/hello-world
    restart: unless-stopped
    ports:
      - "8998:80"
    environment:
      - VIRTUAL_HOST=hello.xrproxy.localy
  echo:
    image: brndnmtthws/nginx-echo-headers
    restart: unless-stopped
    networks:
      - pubnet
    ports:
      - "8997:8080"
    environment:
      - VIRTUAL_HOST=echo.xrproxy.localy
  nginx:
    image: jwilder/nginx-proxy
    restart: unless-stopped
    networks:
      - pubnet
      - ci
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
    ports:
      - "80:80"
    environment:
      - DEFAULT_HOST=echo.xrproxy.localy

and this is the corresponding output. As you can see, none of the "Addresses" array is complete

    {
      "Name": "xcommon_whoami_1",
      "ID": "af2e3bc0bc8c60570c686cb5d4c4dc382975557c29bb5249111ad5e05ab6cf2d",
      "Addresses": [
        {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "8000",
          "HostPort": "8999",
          "Proto": "tcp",
          "HostIP": "0.0.0.0"
        }
      ],
      "Networks": [
        {
          "IP": "172.19.0.2",
          "Name": "xcommon_default",
          "Gateway": "172.19.0.1",
          "EndpointID": "e00dff54dd1704665a1e2a11450de78449a028db636f3e53e6a25635b4d5d1c7",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:13:00:02",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        }
      ],
      "Gateway": "",
      "Hostname": "af2e3bc0bc8c",
      "Image": {
        "Registry": "jwilder",
        "Repository": "whoami",
        "Tag": ""
      },
      "Env": {
        "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "PORT": "8000",
        "VIRTUAL_HOST": "whoami.xcommon.localy"
      },
      "Volumes": {
      },
      "Node": {
        "ID": "",
        "Name": "",
        "Address": {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "",
          "HostPort": "",
          "Proto": "",
          "HostIP": ""
        }
      },
      "Labels": {
        "com.docker.compose.config-hash": "220d558b99f69da89a7104d05475507dc41d7338f15a382bf63c5e458d0b73e9",
        "com.docker.compose.container-number": "1",
        "com.docker.compose.oneoff": "False",
        "com.docker.compose.project": "xcommon",
        "com.docker.compose.service": "whoami",
        "com.docker.compose.version": "1.7.1"
      },
      "IP": "",
      "IP6LinkLocal": "",
      "IP6Global": "",
      "Mounts": null,
      "State": {
        "Running": true
      }
    },
    {
      "Name": "xrproxy_ping_1",
      "ID": "1e47976dce43fb1852d9c7674df1af2a24a3dba0e64a026c17d8fc23ce171731",
      "Addresses": [
        {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "80",
          "HostPort": "8998",
          "Proto": "tcp",
          "HostIP": "0.0.0.0"
        }
      ],
      "Networks": [
        {
          "IP": "172.22.0.3",
          "Name": "xrproxy_default",
          "Gateway": "172.22.0.1",
          "EndpointID": "0a945022bbf8ef79564179b0520b9bfe4e4efa6ba5eecffeae9848608ba05478",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:16:00:03",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        }
      ],
      "Gateway": "",
      "Hostname": "1e47976dce43",
      "Image": {
        "Registry": "dockercloud",
        "Repository": "hello-world",
        "Tag": ""
      },
      "Env": {
        "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "VIRTUAL_HOST": "hello.xrproxy.localy"
      },
      "Volumes": {
      },
      "Node": {
        "ID": "",
        "Name": "",
        "Address": {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "",
          "HostPort": "",
          "Proto": "",
          "HostIP": ""
        }
      },
      "Labels": {
        "com.docker.compose.config-hash": "f5b36b13e63b3b8cc0294c92abd7d0864db94f424c57cdce11c8433f02a0b810",
        "com.docker.compose.container-number": "1",
        "com.docker.compose.oneoff": "False",
        "com.docker.compose.project": "xrproxy",
        "com.docker.compose.service": "ping",
        "com.docker.compose.version": "1.7.1"
      },
      "IP": "",
      "IP6LinkLocal": "",
      "IP6Global": "",
      "Mounts": null,
      "State": {
        "Running": true
      }
    },
    {
      "Name": "xrproxy_echo_1",
      "ID": "ffbb3e6bba579018bc14d9300d5de91be5b2f38b54d7c16ccc78c6ffe5741772",
      "Addresses": [
        {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "8080",
          "HostPort": "8997",
          "Proto": "tcp",
          "HostIP": "0.0.0.0"
        }
      ],
      "Networks": [
        {
          "IP": "172.24.0.3",
          "Name": "xcommon_pubnet",
          "Gateway": "172.24.0.1",
          "EndpointID": "2f5cac19524c80178510c9282556b2568505949f096cf9fb98c61715e305c517",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:18:00:03",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        }
      ],
      "Gateway": "",
      "Hostname": "ffbb3e6bba57",
      "Image": {
        "Registry": "brndnmtthws",
        "Repository": "nginx-echo-headers",
        "Tag": ""
      },
      "Env": {
        "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "VIRTUAL_HOST": "echo.xrproxy.localy"
      },
      "Volumes": {
      },
      "Node": {
        "ID": "",
        "Name": "",
        "Address": {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "",
          "HostPort": "",
          "Proto": "",
          "HostIP": ""
        }
      },
      "Labels": {
        "com.docker.compose.config-hash": "84050a723f31a059e2bdb2a07cdca49fc8ffd1a0c3d70ab17d3f641ebfd7e093",
        "com.docker.compose.container-number": "1",
        "com.docker.compose.oneoff": "False",
        "com.docker.compose.project": "xrproxy",
        "com.docker.compose.service": "echo",
        "com.docker.compose.version": "1.7.1"
      },
      "IP": "",
      "IP6LinkLocal": "",
      "IP6Global": "",
      "Mounts": null,
      "State": {
        "Running": true
      }
    },
    {
      "Name": "xcommon_dockergen_dumpall_run_6",
      "ID": "4319f480d3d6147ab8b88b498efbd15ad16d717ae6503e1d60513cb4aeb25003",
      "Addresses": [

      ],
      "Networks": [
        {
          "IP": "172.18.0.9",
          "Name": "xcommon_ci",
          "Gateway": "172.18.0.1",
          "EndpointID": "02a9053b4911218ea6b75630da8265b354436749afd6156d17fc354bb638e403",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:12:00:09",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        },
        {
          "IP": "172.19.0.3",
          "Name": "xcommon_default",
          "Gateway": "172.19.0.1",
          "EndpointID": "0522d4f98a3a091d15638aad7fe68c6aa3465b5eca8de49df3db89a7f712036e",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:13:00:03",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        },
        {
          "IP": "172.24.0.4",
          "Name": "xcommon_pubnet",
          "Gateway": "172.24.0.1",
          "EndpointID": "548db7aed9b89578fc32562c0b02cd9250d75f6b9a8e09d71bb7bdbebe203bdb",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:18:00:04",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        }
      ],
      "Gateway": "",
      "Hostname": "4319f480d3d6",
      "Image": {
        "Registry": "",
        "Repository": "xcommon_dockergen_dumpall",
        "Tag": ""
      },
      "Env": {
        "DOCKER_HOST": "unix:///tmp/docker.sock",
        "DOWNLOAD_URL": "https://github.com/jwilder/docker-gen/releases/download/0.7.3/docker-gen-alpine-linux-amd64-0.7.3.tar.gz",
        "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "VERSION": "0.7.3"
      },
      "Volumes": {
      },
      "Node": {
        "ID": "",
        "Name": "",
        "Address": {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "",
          "HostPort": "",
          "Proto": "",
          "HostIP": ""
        }
      },
      "Labels": {
        "com.docker.compose.container-number": "6",
        "com.docker.compose.oneoff": "True",
        "com.docker.compose.project": "xcommon",
        "com.docker.compose.service": "dockergen_dumpall",
        "com.docker.compose.version": "1.7.1"
      },
      "IP": "",
      "IP6LinkLocal": "",
      "IP6Global": "",
      "Mounts": [
        {
          "Name": "",
          "Source": "/var/run/docker.sock",
          "Destination": "/tmp/docker.sock",
          "Driver": "",
          "Mode": "ro",
          "RW": false
        }
      ],
      "State": {
        "Running": true
      }
    },
    {
      "Name": "xrproxy_nginx_1",
      "ID": "ea4804a43c3ec2323a101cdd9b5d0732e4b38ddd83e4022d99d5c69e43efa072",
      "Addresses": [
        {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "443",
          "HostPort": "8443",
          "Proto": "tcp",
          "HostIP": "0.0.0.0"
        },
        {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "80",
          "HostPort": "80",
          "Proto": "tcp",
          "HostIP": "0.0.0.0"
        }
      ],
      "Networks": [
        {
          "IP": "172.18.0.8",
          "Name": "xcommon_ci",
          "Gateway": "172.18.0.1",
          "EndpointID": "b0d0e2bb94de305158d4c334a7d9dc6496c8fbfc108778d9b614a62cf5a8f522",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:12:00:08",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        },
        {
          "IP": "172.24.0.2",
          "Name": "xcommon_pubnet",
          "Gateway": "172.24.0.1",
          "EndpointID": "7e85dfebbcac6650a2561585a4b95ede7bf4923173d9774d5d74fe3d93eb9144",
          "IPv6Gateway": "",
          "GlobalIPv6Address": "",
          "MacAddress": "02:42:ac:18:00:02",
          "GlobalIPv6PrefixLen": 0,
          "IPPrefixLen": 16
        }
      ],
      "Gateway": "",
      "Hostname": "ea4804a43c3e",
      "Image": {
        "Registry": "jwilder",
        "Repository": "nginx-proxy",
        "Tag": ""
      },
      "Env": {
        "DEFAULT_HOST": "echo.xrproxy.localy",
        "DOCKER_GEN_VERSION": "0.7.3",
        "DOCKER_HOST": "unix:///tmp/docker.sock",
        "NGINX_VERSION": "1.9.15-1~jessie",
        "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      },
      "Volumes": {
      },
      "Node": {
        "ID": "",
        "Name": "",
        "Address": {
          "IP": "",
          "IP6LinkLocal": "",
          "IP6Global": "",
          "Port": "",
          "HostPort": "",
          "Proto": "",
          "HostIP": ""
        }
      },
      "Labels": {
        "com.docker.compose.config-hash": "8d1bf427beb9922f97f00a53dbd190dd962c82642d7fa6ad1bb2c031fa84808e",
        "com.docker.compose.container-number": "1",
        "com.docker.compose.oneoff": "False",
        "com.docker.compose.project": "xrproxy",
        "com.docker.compose.service": "nginx",
        "com.docker.compose.version": "1.7.1"
      },
      "IP": "",
      "IP6LinkLocal": "",
      "IP6Global": "",
      "Mounts": [
        {
          "Name": "",
          "Source": "/var/run/docker.sock",
          "Destination": "/tmp/docker.sock",
          "Driver": "",
          "Mode": "ro",
          "RW": false
        }
      ],
      "State": {
        "Running": true
      }
    },

joaocc avatar Jul 12 '16 12:07 joaocc

you probably need to set VIRTUAL_HOST environment vars

jedwards1211 avatar Jul 20 '16 02:07 jedwards1211

It (https://github.com/jwilder/docker-gen/issues/196#issuecomment-225325662) could help you.

SAprelov avatar Aug 03 '16 09:08 SAprelov

This repo should no longer handle issues or discussions related to nginx-proxy / the nginx-proxy template, unless there is something we need to change / fix in docker-gen in order to allow a change / fix in nginx-proxy.

buchdag avatar May 16 '24 12:05 buchdag