Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no servers inside upstream in /etc/nginx/conf.d/default.conf when specifying an hostname #344

Closed
daisukixci opened this issue Apr 8, 2021 · 18 comments

Comments

@daisukixci
Copy link

daisukixci commented Apr 8, 2021

I use docker-gen through nginx-proxy and got this nginx-proxy/nginx-proxy#1548 which seems to be linked to docker-gen. It seems it can't find the ip of the other container with netiher /proc/self/cgroup" nor "/proc/self/mountinfo" (It seems I miss understood how the IP of the others containers was found). FYI I use docker swarm on arch, Here is my docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-tp-docker)

Server:
 Containers: 10
  Running: 5
  Paused: 0
  Stopped: 5
 Images: 31
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: REDACTED
  Is Manager: true
  ClusterID: REDACTED
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: REDACTED
  Manager Addresses:
   REDACTED
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e.m
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.11.11-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.59GiB
 Name: REDACTED
 ID: XB5C:65VO:KHNJ:DLXF:NGS2:LDHI:HX34:EOJW:PWSZ:IURK:UKSW:WFCJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: Support for cgroup v2 is experimental
@daisukixci
Copy link
Author

daisukixci commented Apr 8, 2021

Ok my problems was the specified hostname like said in #336 (comment).
I don't see issue to track the regression, so i leave open this one, feel free to close it as my issue is solved by removing hostname entries.

@daisukixci daisukixci changed the title no servers inside upstream in /etc/nginx/conf.d/default.conf no servers inside upstream in /etc/nginx/conf.d/default.conf when specifying an hostname Apr 8, 2021
@Syphdias
Copy link
Contributor

I experience the same issue. No upstream servers. I use the nginx.tmpl from nginx-proxy. Like suggested by the docker hub page.

I tried to debug it and added some lines to the template at the top:

{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
{{ $CurrentContainer }} 
{{ where $ "ID" .Docker.CurrentContainerID }}

Line 1 is in there by default and is later used to compare if a potential backend container is in the same network as the current container. Line 2 and 3 I added and it looks like they are empty:

<no value> 
[]

I'm not good at go templates but I see there is a RuntimeContainer struct with Networks in the README (templateing). But I cannot figure out how to access it to fix the template. .RuntimeContainer.Networks did not work.

@buchdag
Copy link
Member

buchdag commented Apr 10, 2021

@Syphdias could you post the result of docker inspect youdockergencontainer ?

@Syphdias
Copy link
Contributor

Syphdias commented Apr 10, 2021

Sure

❯ docker-compose exec revproxy-gen /usr/local/bin/docker-gen --version # for good measure
0.7.5
❯ docker inspect revproxy-gen
[
    {
        "Id": "d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e",
        "Created": "2021-04-10T15:13:25.659568865Z",
        "Path": "/usr/local/bin/docker-gen",
        "Args": [
            "-notify-sighup",
            "revproxy",
            "-watch",
            "-only-exposed",
            "/etc/docker-gen/templates/nginx.tmpl",
            "/etc/nginx/conf.d/default.conf"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 221692,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-04-10T20:11:19.517464833Z",
            "FinishedAt": "2021-04-10T20:11:18.709340623Z"
        },
        "Image": "sha256:a467dff5e74dfc91427f4b0403fb5543584a5fb4e429d34d2e94b2ea337a8215",
        "ResolvConfPath": "/var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/hostname",
        "HostsPath": "/var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/hosts",
        "LogPath": "/var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e-json.log",
        "Name": "/revproxy-gen",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/var/run/docker.sock:/tmp/docker.sock:rw",
                "/home/syphdias/docker/revproxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "revproxy_backend",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [
                "09f7256e82f3f08d2efb8b0135a0aef213c47c3b111d09358f8735f0cc0c321f:rw"
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a-init/diff:/var/lib/docker/overlay2/4e3589f7badb112db34b5e938ee3219693bca0aa037b4eea3aee9d3425981260/diff:/var/lib/docker/overlay2/7148944f948af3a2193fcdcfe9255032a505e62bbf7501c91db8925df37f5e2b/diff:/var/lib/docker/overlay2/a354b31fa8aad270d396da5227bc5b2f1a1e62c0db59a8ad845fd4e192ced0b1/diff",
                "MergedDir": "/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a/merged",
                "UpperDir": "/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a/diff",
                "WorkDir": "/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "revproxy_nginx-conf",
                "Source": "/var/lib/docker/volumes/revproxy_nginx-conf/_data",
                "Destination": "/etc/nginx/conf.d",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/tmp/docker.sock",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/home/syphdias/docker/revproxy/nginx.tmpl",
                "Destination": "/etc/docker-gen/templates/nginx.tmpl",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/home/syphdias/docker-data/certs/letsencrypt/live/redacted.com/fullchain.pem",
                "Destination": "/etc/nginx/certs/redacted.com.crt",
                "Mode": "",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/home/syphdias/docker-data/certs/letsencrypt/live/redacted.com/privkey.pem",
                "Destination": "/etc/nginx/certs/redacted.com.key",
                "Mode": "",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "d8411145f6d7",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "SSL_POLICY=Mozilla-Modern",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "VERSION=0.7.5",
                "DOCKER_HOST=unix:///tmp/docker.sock"
            ],
            "Cmd": [
                "-notify-sighup",
                "revproxy",
                "-watch",
                "-only-exposed",
                "/etc/docker-gen/templates/nginx.tmpl",
                "/etc/nginx/conf.d/default.conf"
            ],
            "Image": "jwilder/docker-gen:0.7.5",
            "Volumes": {
                "/etc/docker-gen/templates/nginx.tmpl": {},
                "/tmp/docker.sock": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/usr/local/bin/docker-gen"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "6c7e681cd63280d323b72baa96aa6215cab8beb88473d7834d50ee9340854ff5",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "revproxy",
                "com.docker.compose.project.config_files": "docker-compose.yml",
                "com.docker.compose.project.working_dir": "/home/syphdias/docker/revproxy",
                "com.docker.compose.service": "revproxy-gen",
                "com.docker.compose.version": "1.28.6",
                "maintainer": "Jason Wilder <mail@jasonwilder.com>"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "69c1087908801795f67f0a2f862d6a70a7f214f1d1d254c603df914d9626c081",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/69c108790880",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "revproxy_backend": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "revproxy-gen",
                        "d8411145f6d7"
                    ],
                    "NetworkID": "c70404d73a369d78551310a1d3414c6a59b3c8f714653441bac558709e1716f8",
                    "EndpointID": "ea7b1ccf1abe3b0631612f989aa312304a4830bc7196ef675d0dcf4197277b7b",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.9",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:09",
                    "DriverOpts": null
                }
            }
        }
    }
]

Edit: Just in case:

❯ docker --version
Docker version 20.10.5, build 55c4c88966

@buchdag
Copy link
Member

buchdag commented Apr 11, 2021

@Syphdias thanks, could you also post results of

 docker exec revproxy-gen cat /proc/1/cpuset
 docker exec revproxy-gen cat /proc/self/cgroup
 docker exec revproxy-gen cat /proc/self/mountinfo

@Syphdias
Copy link
Contributor

Will check as soon as I am home. I guess you are suspecting not enough privileges or capabilities?

@buchdag
Copy link
Member

buchdag commented Apr 11, 2021

The last two files are currently used to search for the container ID, the first one will be added by #336. I'm curious to see if your container ID is actually inside one of those files, and if not why / how should we update the GetCurrentContainerID() function to work in this case.

@Syphdias
Copy link
Contributor

❯ docker exec revproxy-gen cat /proc/1/cpuset
/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
❯ docker exec revproxy-gen cat /proc/self/cgroup
12:rdma:/
11:cpuset:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
10:blkio:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
9:freezer:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
8:hugetlb:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
7:memory:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
6:perf_event:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
5:devices:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
4:pids:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
3:net_cls,net_prio:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
2:cpu,cpuacct:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
1:name=systemd:/docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e
0::/system.slice/docker.service
❯ docker exec revproxy-gen cat /proc/self/mountinfo
1422 1337 0:68 / / rw,relatime master:459 - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/ZSACOL773WXPGHNWG2EH7AH6FO:/var/lib/docker/overlay2/l/V7XSR656VLMXCMUBSAA4DV3I2G:/var/lib/docker/overlay2/l/HH2GJ6T6C7QKS6ADY3DLKO6SBB:/var/lib/docker/overlay2/l/LOUMZPZEZQAFTW5AAAFBK4A5RH,upperdir=/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a/diff,workdir=/var/lib/docker/overlay2/cd31ae31ae1aede18ad8c98c5f46703a9b5b41f1ddbb58477e0867c9a485bc6a/work,index=off
1423 1422 0:94 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
1424 1422 0:95 / /dev rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1425 1424 0:96 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
1426 1422 0:97 / /sys ro,nosuid,nodev,noexec,relatime - sysfs sysfs ro
1427 1426 0:98 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755,inode64
1428 1427 0:30 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/systemd ro,nosuid,nodev,noexec,relatime master:11 - cgroup cgroup rw,xattr,name=systemd
1429 1427 0:33 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/cpu,cpuacct ro,nosuid,nodev,noexec,relatime master:15 - cgroup cgroup rw,cpu,cpuacct
1430 1427 0:34 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/net_cls,net_prio ro,nosuid,nodev,noexec,relatime master:16 - cgroup cgroup rw,net_cls,net_prio
1431 1427 0:35 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/pids ro,nosuid,nodev,noexec,relatime master:17 - cgroup cgroup rw,pids
1432 1427 0:36 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime master:18 - cgroup cgroup rw,devices
1433 1427 0:37 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/perf_event ro,nosuid,nodev,noexec,relatime master:19 - cgroup cgroup rw,perf_event
1434 1427 0:38 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime master:20 - cgroup cgroup rw,memory
1435 1427 0:39 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/hugetlb ro,nosuid,nodev,noexec,relatime master:21 - cgroup cgroup rw,hugetlb
1436 1427 0:40 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/freezer ro,nosuid,nodev,noexec,relatime master:22 - cgroup cgroup rw,freezer
1437 1427 0:41 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/blkio ro,nosuid,nodev,noexec,relatime master:23 - cgroup cgroup rw,blkio
1438 1427 0:42 /docker/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e /sys/fs/cgroup/cpuset ro,nosuid,nodev,noexec,relatime master:24 - cgroup cgroup rw,cpuset
1439 1427 0:43 / /sys/fs/cgroup/rdma ro,nosuid,nodev,noexec,relatime master:25 - cgroup cgroup rw,rdma
1440 1424 0:87 / /dev/mqueue rw,nosuid,nodev,noexec,relatime - mqueue mqueue rw
1441 1424 0:99 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,size=65536k,inode64
1442 1422 0:24 /docker.sock /tmp/docker.sock rw,nosuid,nodev,relatime - tmpfs run rw,mode=755,inode64
1443 1422 259:2 /var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/hosts /etc/hosts rw,noatime - ext4 /dev/nvme0n1p2 rw
1444 1422 259:2 /var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/resolv.conf /etc/resolv.conf rw,noatime - ext4 /dev/nvme0n1p2 rw
1445 1422 259:2 /var/lib/docker/containers/d8411145f6d775560b9169f5347d433a6ea32b01fb9a3903d50a98bae4a0421e/hostname /etc/hostname rw,noatime - ext4 /dev/nvme0n1p2 rw
1446 1422 259:2 /var/lib/docker/volumes/revproxy_nginx-conf/_data /etc/nginx/conf.d rw,noatime master:1 - ext4 /dev/nvme0n1p2 rw
1448 1422 259:2 /home/syphdias/docker/revproxy/nginx.tmpl /etc/docker-gen/templates/nginx.tmpl rw,noatime - ext4 /dev/nvme0n1p2 rw
1449 1422 259:2 /home/syphdias/docker-data/certs/letsencrypt/archive/example.com/fullchain6.pem /etc/nginx/certs/example.com.crt ro,noatime - ext4 /dev/nvme0n1p2 rw
1450 1422 259:2 /home/syphdias/docker-data/certs/letsencrypt/archive/example.com/privkey6.pem /etc/nginx/certs/example.com.key ro,noatime - ext4 /dev/nvme0n1p2 rw
1338 1423 0:94 /bus /proc/bus ro,relatime - proc proc rw
1339 1423 0:94 /fs /proc/fs ro,relatime - proc proc rw
1340 1423 0:94 /irq /proc/irq ro,relatime - proc proc rw
1341 1423 0:94 /sys /proc/sys ro,relatime - proc proc rw
1342 1423 0:94 /sysrq-trigger /proc/sysrq-trigger ro,relatime - proc proc rw
1343 1423 0:181 / /proc/asound ro,relatime - tmpfs tmpfs ro,inode64
1344 1423 0:182 / /proc/acpi ro,relatime - tmpfs tmpfs ro,inode64
1345 1423 0:95 /null /proc/kcore rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1346 1423 0:95 /null /proc/keys rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1347 1423 0:95 /null /proc/latency_stats rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1349 1423 0:95 /null /proc/timer_list rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1350 1423 0:95 /null /proc/sched_debug rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
1351 1423 0:183 / /proc/scsi ro,relatime - tmpfs tmpfs ro,inode64
1352 1426 0:184 / /sys/firmware ro,relatime - tmpfs tmpfs ro,inode64

@Syphdias
Copy link
Contributor

I saw the merge #345. Will the template need to change? Because I tried latest it and it's still broken:

❯ doc exec revproxy-gen head -3 /etc/docker-gen/templates/nginx.tmpl
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
{{ $CurrentContainer }} 
{{ where $ "ID" .Docker.CurrentContainerID }}
❯ doc exec revproxy-gen /usr/local/bin/docker-gen -only-exposed /etc/docker-gen/templates/nginx.tmpl |head -2
<no value> 
[]
❯ docker inspect revproxy-gen |jq '.[].Image'
"sha256:c333921e96464c8abdc5d5db1a724a8f6ad5a358b2c9362c4e93d64d9d9a95ff"
❯ docker inspect c333921e9646 |jq '.[].RepoDigests[]'
"jwilder/docker-gen@sha256:4a88cb1ddb519b646e2966eba2d1b810189b906229eb72fb5b6c5faff289c3ee"

@Syphdias
Copy link
Contributor

Oh, btw .Docker.CurrentContainerID yields the same result as docker inspect revproxy-gen |jq '.[].Id' -r.

@Syphdias
Copy link
Contributor

Found a fix:
-only-exposed excludes the docker-gen container from the variable $ thus it can no longer be found by ID. I guess there are two options:

  1. expose a port
  2. don't use -only-exposed

@Insomniacnomis
Copy link

Found a fix:
-only-exposed excludes the docker-gen container from the variable $ thus it can no longer be found by ID. I guess there are two options:

  1. expose a port
  2. don't use -only-exposed

This fixed it for me

@buchdag
Copy link
Member

buchdag commented Aug 3, 2021

@Syphdias is it still broken with #356 merged in ?

@Syphdias
Copy link
Contributor

@buchdag, I tired to test this by building from source with make and docker cp-ing the binary into my container but I have trouble getting it to work at all. Outside the container it works. Maybe I need to build it differently?

bash-5.1# ldd /usr/local/bin/docker-gen
/lib/ld-musl-x86_64.so.1: /usr/local/bin/docker-gen: Not a valid dynamic program
bash-5.1#
bash-5.1# ldd /usr/local/bin/docker-gen2
  /lib64/ld-linux-x86-64.so.2 (0x7f1f6cceb000)
  libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f1f6cceb000)
  libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f1f6cceb000)

@JanMalte
Copy link

@Syphdias is it still broken with #356 merged in ?

Using the 0.9.0 docker image, this is still an issue. Exposing a random port seems to fix this issue.

@oliv3r
Copy link
Contributor

oliv3r commented May 31, 2023

Seeing the same issue, using the template from this repo, which is 8 years old. Is it up to date?

I'm running 0.10.4-22-gedc74cc docker image, via compose with my command being:

      -endpoint 'unix:///var/run/docker.sock'
      -keep-blank-lines
      -notify "echo 'Change detected!'"
      -wait 1s:3s
      -watch
      '/etc/docker-gen/templates/nginx.tmpl'

(yes, it dumps it to the console only).

The endpoint I had to added, because the default (unlike the documentation states) is /tmp/docker.sock, set via DOCKER_HOST somehow.

Docker-get does see changes when I start/stop an container; but then just states the default entry isn't any different, and generates something near-empty.

riley-docker-gen-1  | 2023/05/31 20:17:16 Received event die for container 6410dd7b32cf
riley-docker-gen-1  | 2023/05/31 20:17:17 Received event stop for container 6410dd7b32cf
riley-docker-gen-1  | 2023/05/31 20:17:18 Debounce minTimer fired
riley-docker-gen-1  | server {
riley-docker-gen-1  |   listen 80 default_server;
riley-docker-gen-1  |   server_name _; # This is just an invalid value which will never trigger on a real hostname.
riley-docker-gen-1  |   error_log /proc/self/fd/2;
riley-docker-gen-1  |   access_log /proc/self/fd/1;
riley-docker-gen-1  |   return 503;
riley-docker-gen-1  | }

The container ID is correct, and running docker inspect 6410dd7b32cf within the docker-get (after apk add) shows up the usual info.

What magic is needed to make things work/debug? Are there any special labels needed on the origin containers to part of parsing? When turning on 'only published' and other options, I do actually see correct numbers in the output as well.

As a 'expose random port' I used 65535:65535/tcp but even this made no difference. Is my docker host too old? I see alpine has 23.06 and I only have Docker version 20.10.17, build 100c701 which was 'stable' from docker.com, but I see that a few months ago 24.02 was bumped to stable. Will try that next ... also 24.02 behaves the same.

EDIT:
Never mind; I left out the VIRTUAL_HOST variable, which was not very clear in the documentation. I've added it here: #530

@buchdag
Copy link
Member

buchdag commented Jun 7, 2023

Seeing the same issue, using the template from this repo, which is 8 years old. Is it up to date?

@oliv3r no this template isn't up to date. The templates in the repo were meant as minimal examples only and unfortunately aren't really maintained. In the case of nginx reverse proxy template, there is an actively maintained version, the one used in nginx-proxy/nginx-proxy.

@oliv3r
Copy link
Contributor

oliv3r commented Jun 9, 2023

I switched to using the template linked above as it does everything I wanted it to do :) Took some time to figure out how the template worked though. But I still think the template in this repo should work, even if it is basic, as it is used as a 'starting point'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants