jittering / traefik-kop

A dynamic docker->redis->traefik discovery agent
MIT License
179 stars 13 forks source link

Docker automatic port map not recognized #6

Closed FilipK-CZ closed 2 years ago

FilipK-CZ commented 2 years ago

When a port is automatically assigned by the docker, Traefik Kop does not recognize the port and uses the image port

Option "Publish all exposed network ports to random host ports"

test | healthy |   | - | registry.domain.cz/webcore:latest | 2022-02-03 23:26:20 | 172.20.1.8 | 49157:80 traefik.enable | true traefik.http.routers.test.rule | host(test.domain.cz)

test2 | healthy |   | - | registry.domain.cz/webcore:latest | 2022-02-06 14:29:25 | 172.20.1.9 | 49159:80 traefik.enable | true traefik.http.routers.test2.rule | host(test2.domain.cz)

Test is manualy set, Test2 is set by docker traefik/http/services/test/loadBalancer/servers/0/urls: http://10.0.10.20:49154 traefik/http/services/test2/loadBalancer/servers/0/url: http://10.0.10.20:80

chetan commented 2 years ago

Thanks. I wasn't aware of this option. Will look into it.

chetan commented 2 years ago

Just pushed v0.10 which supports this mode. Let me know if you run into any issues!

FilipK-CZ commented 2 years ago

obrazek obrazek obrazek

Not working, maybe the problem is that ipv6 is enabled?

chetan commented 2 years ago

Right, in this case there's actually multiple bindings for that port (3000) and so it's giving up as it's unsure what to do there. Can you provide the output of docker inspect on that container? That'll help me figure out if it can be handled cleanly.

FilipK-CZ commented 2 years ago
[
    {
        "Id": "7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb",
        "Created": "2022-02-16T09:17:49.078100439Z",
        "Path": "/run.sh",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 2372413,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-02-16T09:17:52.302957728Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:89c85292a45c94f18aafae59f51b1a0078b93c16f245d0e8bfab3f9f39f6b46c",
        "ResolvConfPath": "/data/DockerHome/containers/7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb/resolv.conf",
        "HostnamePath": "/data/DockerHome/containers/7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb/hostname",
        "HostsPath": "/data/DockerHome/containers/7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb/hosts",
        "LogPath": "/data/DockerHome/containers/7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb/7319b6f1218bead3299f30635c0d7e49b74649e887389230f938ba967ffa6efb-json.log",
        "Name": "/Grafana",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/data/Docker/Grafana:/var/lib/grafana"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "Public",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": [
                "AUDIT_WRITE",
                "CHOWN",
                "DAC_OVERRIDE",
                "FOWNER",
                "FSETID",
                "KILL",
                "MKNOD",
                "NET_BIND_SERVICE",
                "NET_RAW",
                "SETFCAP",
                "SETGID",
                "SETPCAP",
                "SETUID",
                "SYS_CHROOT"
            ],
            "CapDrop": [
                "AUDIT_CONTROL",
                "BLOCK_SUSPEND",
                "DAC_READ_SEARCH",
                "IPC_LOCK",
                "IPC_OWNER",
                "LEASE",
                "LINUX_IMMUTABLE",
                "MAC_ADMIN",
                "MAC_OVERRIDE",
                "NET_ADMIN",
                "NET_BROADCAST",
                "SYSLOG",
                "SYS_ADMIN",
                "SYS_BOOT",
                "SYS_MODULE",
                "SYS_NICE",
                "SYS_PACCT",
                "SYS_PTRACE",
                "SYS_RAWIO",
                "SYS_RESOURCE",
                "SYS_TIME",
                "SYS_TTY_CONFIG",
                "WAKE_ALARM"
            ],
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [],
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": true,
            "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": [],
            "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"
            ],
            "Init": false
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/data/DockerHome/overlay2/da7eb3e8a66b7c62485ac25980b779b92b4f54011645618f86e16943fc35482f-init/diff:/srv/data/DockerHome/overlay2/39ceb17eb07807bfcdba636408276b636063e3e9bb3cf4ad6f48e4a5960b0ea2/diff:/srv/data/DockerHome/overlay2/b1b2931ab51a38cdf6a98a03fcdb3d27a858844e3a33190c148387e347897b66/diff:/srv/data/DockerHome/overlay2/72dee385c41bca727e4ce50692e9aa44e767e14da63172fc3f1aeff07324ab45/diff:/srv/data/DockerHome/overlay2/2267fe0705ae60ea9633228e5da29f75fe7c128f17301e3d70a750d8543f12bd/diff:/srv/data/DockerHome/overlay2/7c292475dd07e9c3c13b0e65ab88f99ac3658ed37888927e258ba6fd4f260366/diff:/srv/data/DockerHome/overlay2/c4adb998e40074dba475b5265dc9a6982e6d1cbe06d2015f2a92e3a6002809b4/diff:/srv/data/DockerHome/overlay2/713c1994f8191b3f6a9ead5b951acd8bd4a3e6643312b0f7c27dbb8bceb6e27b/diff:/srv/data/DockerHome/overlay2/c00ff8ae7127d2ff17813f5f81f701acaf34bfb8ac2bd0d39df59fabae46e474/diff:/srv/data/DockerHome/overlay2/4d934d7737d591e9e2ec4b1a11229d781ff07eb0e841b932bff652db7cb4ad7c/diff:/srv/data/DockerHome/overlay2/3c11457b539d64b3648b4d1f8ba8d0fc18f48efc8fcf6f513960a7ca65885bf7/diff",
                "MergedDir": "/data/DockerHome/overlay2/da7eb3e8a66b7c62485ac25980b779b92b4f54011645618f86e16943fc35482f/merged",
                "UpperDir": "/data/DockerHome/overlay2/da7eb3e8a66b7c62485ac25980b779b92b4f54011645618f86e16943fc35482f/diff",
                "WorkDir": "/data/DockerHome/overlay2/da7eb3e8a66b7c62485ac25980b779b92b4f54011645618f86e16943fc35482f/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/data/Docker/Grafana",
                "Destination": "/var/lib/grafana",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "8344da1c85d3",
            "Domainname": "",
            "User": "grafana",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GF_PATHS_CONFIG=/etc/grafana/grafana.ini",
                "GF_PATHS_DATA=/var/lib/grafana",
                "GF_PATHS_HOME=/usr/share/grafana",
                "GF_PATHS_LOGS=/var/log/grafana",
                "GF_PATHS_PLUGINS=/var/lib/grafana/plugins",
                "GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
            ],
            "Cmd": null,
            "Image": "grafana/grafana:latest",
            "Volumes": {
                "/var/lib/grafana": {}
            },
            "WorkingDir": "/usr/share/grafana",
            "Entrypoint": [
                "/run.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "traefik.enable": "true",
                "traefik.http.routers.grafana.rule": "Host(`grafana.domain.cz`)"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "8a25a839a8ae29548706a804082f2265bbdaebc6902956c18a964ed9f7e1563e",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "3000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "49160"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "49160"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/8a25a839a8ae",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "Public": {
                    "IPAMConfig": {},
                    "Links": null,
                    "Aliases": [
                        "8344da1c85d3",
                        "7319b6f1218b"
                    ],
                    "NetworkID": "32003258b35cad946479765fc8bd16134a1f344fca52d1410673e42b65e20607",
                    "EndpointID": "3685dda4fc3c7bc57d61f6555360a6b44996d839ea9593ecdfb4c1e70786aeca",
                    "Gateway": "172.20.0.1",
                    "IPAddress": "172.20.1.5",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:41:ab:14:01:05",
                    "DriverOpts": null
                }
            }
        }
    }
]
FilipK-CZ commented 2 years ago

Any update?

chetan commented 2 years ago

@FilipK-CZ just pushed a fix and released v0.10.1