avast / gradle-docker-compose-plugin

Simplifies usage of Docker Compose for integration testing in Gradle environment.
MIT License
413 stars 96 forks source link

Incorrect host IP for Windows + WSL2 #294

Closed jonnyzzz closed 2 years ago

jonnyzzz commented 3 years ago

I'm using the plugin in Gradle inside WSL2 ubuntu instance on Windows. The TCP probing feature was using the incorrect IP of to probe-started containers.

The workaround was to set the SERVICES_HOST=0.0.0.0 before starting the Gradle build. It looks like the code does not work correctly for such a setup (Windows + WSL2, running in WSL2)

augi commented 3 years ago

Hello, thank you for reporting this issue! πŸ‘

As you can see in the getContainerHost method, it logs how it decided to choose the IP address. Could you please share this log message from your setup? πŸ™

jonnyzzz commented 3 years ago

It was stuck on the message like image And this is the docker inspect output image It seems like it decided to use "Gateway": "172.21.0.1",, which was the wrong answer

augi commented 3 years ago

Could you please share the exact log message? It would help to identify why exactly it decided to use this value. Thanks! πŸ™

jonnyzzz commented 3 years ago

I’m not sure I understand what is the exact message that you are referring to

On Fri 30. Apr 2021 at 16:09, Michal AugustΓ½n @.***> wrote:

Could you please share the exact log message? It would help to identify why exactly it decided to use this value. Thanks! πŸ™

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/avast/gradle-docker-compose-plugin/issues/294#issuecomment-830121549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB6TLY3GXMEKDAJSFEGRRDTLK2Y5ANCNFSM434E2WNQ .

-- Best regards, Eugene Petrenko https://jonnyzzz.com

augi commented 3 years ago

The log message coming from getContainerHost method, you linked in your first message.

So e.g. something like "Will use $gateway as host of $serviceName because it is using HOST network"

embee1981 commented 3 years ago

I'm seeing the same issue with WSL2. This is the output from gradle :

4:45:15 pm: Executing task 'composeUp'...

Running Gradle on WSL...

> Task :service:composeUp
ldap uses an image, skipping
Creating network "d84d224b2f0b4118656c0c74a94976ec_service__default" with the default driver

Will use 172.25.0.1 (network d84d224b2f0b4118656c0c74a94976ec_service__default) as host of ldap
Probing TCP socket on 172.25.0.1:389 of 'ldap_test'
Waiting for TCP socket on 172.25.0.1:389 of 'ldap_test' (Connection timed out (Connection timed out))

Similar to jonnyzzz ,

dockerCompose {
    environment.put 'SERVICES_HOST', '0.0.0.0'
}

gets it to work OK

docker inspect output for the network settings is :

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "ffe33ed80d3488fa9f8d23492b13b8bb5a3fb324e40abd56ae3a65e9da541988",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "389/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "389"
                    }
                ],
                "636/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/ffe33ed80d34",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "d84d224b2f0b4118656c0c74a94976ec_service__default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "ldap",
                        "21738f3c379a"
                    ],
                    "NetworkID": "9e20329a0a793181c037e02331eb357d52f6620d48960f698593e702c96b9cd9",
                    "EndpointID": "d33e7704356e15695854936bf8d603bb362816428f42bc249722cf74af98ba74",
                    "Gateway": "172.25.0.1",
                    "IPAddress": "172.25.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DriverOpts": null
                }
            }
        }
dboreham commented 2 years ago

Same issue here fwiw:

Will use 172.24.0.1 (network 70b00b10fd7ae1d175da435ce32bcfcf_medicalschema__default) as host of db
Will use 172.24.0.1 (network 70b00b10fd7ae1d175da435ce32bcfcf_medicalschema__default) as host of service

I'd be happy to debug this since I have it reproduced. lmk if that would be helpful.

augi commented 2 years ago

Hello @dboreham , it would be great if you could share the output of docker inspect (inspection of the container) and also docker network inspect (to get information about the network the container uses).

I'm asking for this because if I understand the issue right, we should detect the WSL network and then use localhost instead of the network gateway.

dboreham commented 2 years ago

Will do that when I have a minute. WSL2 is different in that the kernel(s) magically map ports into the host. So the peer address seen by the container isn't actually the host.

augi commented 2 years ago

Yeah, getting the right host is kind of magic, see this code.

Please share the whole output of the inspect commands, e.g. HostConfig.NetworkMode of the container inspection is very important πŸ™

dboreham commented 2 years ago

inspect_network.json:

[
    {
        "Name": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__default",
        "Id": "b4681502fb2a5750b091e2978d258acea06fceec75f0028a1fac5637ea6f36ed",
        "Created": "2021-12-14T16:04:47.6208997Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "192.168.0.0/20",
                    "Gateway": "192.168.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023": {
                "Name": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__microservice_1",
                "EndpointID": "23175cc2ac7f458cd5a1067af6f7995bd8f005b7597ab77ddb05f9b236d04046",
                "MacAddress": "02:42:c0:a8:00:02",
                "IPv4Address": "192.168.0.2/20",
                "IPv6Address": ""
            },
            "d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820": {
                "Name": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__db_1",
                "EndpointID": "ad04c25da425472a40be71972821619b2fb3c62eeada6543548b068209793db4",
                "MacAddress": "02:42:c0:a8:00:03",
                "IPv4Address": "192.168.0.3/20",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "70b00b10fd7ae1d175da435ce32bcfcf_projectname_",
            "com.docker.compose.version": "1.29.2"
        }
    }
]

inspect_db.json:

[
    {
        "Id": "d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820",
        "Created": "2021-12-14T16:04:47.7440398Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "postgres"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 11953,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-12-14T16:04:48.4528624Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:e94a3bb612246f1f672a0d11fbd16415e2f95d308b37d38deaa8c2bd3c0116d8",
        "ResolvConfPath": "/var/lib/docker/containers/d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820/hostname",
        "HostsPath": "/var/lib/docker/containers/d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820/hosts",
        "LogPath": "/var/lib/docker/containers/d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820/d80450cafd365918ab382dcf698c03c5ff1aa475bff989f91417f428df059820-json.log",
        "Name": "/70b00b10fd7ae1d175da435ce32bcfcf_projectname__db_1",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/home/david/projects/carbon/projectname/src/integrationTest/resources/create_db_tables_for_tests.sql:/docker-entrypoint-initdb.d/create_db_tables_for_tests.sql:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__default",
            "PortBindings": {
                "5432/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "0"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "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/81d897021cf222bb7fdfd5e1e61e70fadaeeec27a9f3ac3e6b19d3c61b343a5c-init/diff:/var/lib/docker/overlay2/08a2a347dd8b35a89a968cf9f9041a1f70dd68ed1267903481d4df48ab105d73/diff:/var/lib/docker/overlay2/b5b77d70581c2b92d5f4c760837356866ee5fabfb7994b034f3566b5dbfa001e/diff:/var/lib/docker/overlay2/272acf2e68f45b83b2eb0893dc1211f6a441a7c22ee52caf890645625c0c7028/diff:/var/lib/docker/overlay2/618e1cbd6b6ada7da3a8958122baa585b09f125f82c846388ea7d20c6f3e5e75/diff:/var/lib/docker/overlay2/dcc65856e0e14dbe5da88444838f64080962a45aa28cad80a2e609a37fced714/diff:/var/lib/docker/overlay2/889b9fce41799a7dc1e94f479bc598591b8bb8626614b9b1c836f5015e1b6fed/diff:/var/lib/docker/overlay2/2471e7d4c7ec450d005a3e417eb8b453b425f58b00808f1261267e6ba796e789/diff:/var/lib/docker/overlay2/63b0621f5dd1f7fbd82fd8703b4fddb49ce8cdd84eaea9b7a20409202d25fdc0/diff:/var/lib/docker/overlay2/dcfdd660237b1ec92600f28b04aad3a208ef76698d787a98ded6311e5ef14a48/diff:/var/lib/docker/overlay2/2447465bbc041963199ce26c2ccde417d329c1cf8bd8dc31a2a59303d19f9083/diff:/var/lib/docker/overlay2/6e8c435d253f90a636d051e9a50a9ff5393c1c08404203915aaf61ff72f16fc1/diff:/var/lib/docker/overlay2/6638a7c1cd9a77871c26de4add449ba96c22d23b5d532897b80056e84e739e8a/diff:/var/lib/docker/overlay2/4933312aa0437485db128a8f77b4ce355e3022af546528bf5e28103152ce0311/diff",
                "MergedDir": "/var/lib/docker/overlay2/81d897021cf222bb7fdfd5e1e61e70fadaeeec27a9f3ac3e6b19d3c61b343a5c/merged",
                "UpperDir": "/var/lib/docker/overlay2/81d897021cf222bb7fdfd5e1e61e70fadaeeec27a9f3ac3e6b19d3c61b343a5c/diff",
                "WorkDir": "/var/lib/docker/overlay2/81d897021cf222bb7fdfd5e1e61e70fadaeeec27a9f3ac3e6b19d3c61b343a5c/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/home/david/projects/carbon/projectname/src/integrationTest/resources/create_db_tables_for_tests.sql",
                "Destination": "/docker-entrypoint-initdb.d/create_db_tables_for_tests.sql",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "d3d6b603bc0f3eb831d24286fed709f526b9895872b1e5668681e4792cd1aee2",
                "Source": "/var/lib/docker/volumes/d3d6b603bc0f3eb831d24286fed709f526b9895872b1e5668681e4792cd1aee2/_data",
                "Destination": "/var/lib/postgresql/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "d80450cafd36",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5432/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "POSTGRES_PASSWORD=db",
                "POSTGRES_USER=db",
                "POSTGRES_DB=db",
                "POSTGRES_HOST_AUTH_METHOD=trust",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/14/bin",
                "GOSU_VERSION=1.14",
                "LANG=en_US.utf8",
                "PG_MAJOR=14",
                "PG_VERSION=14.1-1.pgdg110+1",
                "PGDATA=/var/lib/postgresql/data"
            ],
            "Cmd": [
                "postgres"
            ],
            "Image": "postgres:14",
            "Volumes": {
                "/docker-entrypoint-initdb.d/create_db_tables_for_tests.sql": {},
                "/var/lib/postgresql/data": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "5d4d556446865070fd419fa2bef2ec43e6fc3b90602b2b34cecc33413ed3e4db",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "70b00b10fd7ae1d175da435ce32bcfcf_projectname_",
                "com.docker.compose.project.config_files": "docker-compose.yaml",
                "com.docker.compose.project.working_dir": "/home/david/projects/carbon/projectname",
                "com.docker.compose.service": "db",
                "com.docker.compose.version": "1.29.2",
                "desktop.docker.io/wsl-distro": "Ubuntu-18.04"
            },
            "StopSignal": "SIGINT"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "6119fca11aa49de56819e4fea00f238123103a86e51f05e68be68f7e59a4a1d0",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "5432/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "57173"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/6119fca11aa4",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "70b00b10fd7ae1d175da435ce32bcfcf_projectname__default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "db",
                        "d80450cafd36"
                    ],
                    "NetworkID": "b4681502fb2a5750b091e2978d258acea06fceec75f0028a1fac5637ea6f36ed",
                    "EndpointID": "ad04c25da425472a40be71972821619b2fb3c62eeada6543548b068209793db4",
                    "Gateway": "192.168.0.1",
                    "IPAddress": "192.168.0.3",
                    "IPPrefixLen": 20,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:c0:a8:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]

inspect_service.json:

[
    {
        "Id": "22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023",
        "Created": "2021-12-14T16:04:47.7446036Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "./scripts/run.sh"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 11952,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-12-14T16:04:48.5034233Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:b39567abf36a54c2f18094a0c3c13282bdb70b527a698d6a49aeea14eb84e19f",
        "ResolvConfPath": "/var/lib/docker/containers/22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023/hostname",
        "HostsPath": "/var/lib/docker/containers/22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023/hosts",
        "LogPath": "/var/lib/docker/containers/22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023/22662bccbabb93d54a928957a1e86f15fbd412fa6b916cb68859976249e25023-json.log",
        "Name": "/70b00b10fd7ae1d175da435ce32bcfcf_projectname__microservice_1",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__default",
            "PortBindings": {
                "9003/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "0"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "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/9ec002ab2bfcc57a140d65ff6e9714f11155d7c31a0f77261d6fa7849d1a826e-init/diff:/var/lib/docker/overlay2/410aebc2c37115c9ab5374a15eed9e54cade2286652d2a2776e7f1776c3cd598/diff:/var/lib/docker/overlay2/7484b2662b7da2fe50ae8e571a66ca7147f245f559f4468994e0696202fa1f23/diff:/var/lib/docker/overlay2/24950e07bb9c5e29d188461d78ccf97069e578185432259936be40cd8a5c4ab9/diff:/var/lib/docker/overlay2/92438a6d6178de9f07e69f7fcc3200d39a48757d313897d33314c816a9afe5a7/diff:/var/lib/docker/overlay2/ec62b1aa52d4931e7ce79e830017b9e445211e159c68662e3b5d76505f4dd95d/diff:/var/lib/docker/overlay2/192d66bb2d56cd55611310957123cd1426f3b9b7ade891a9a751087686ae9736/diff:/var/lib/docker/overlay2/00b58bccc9f63a8fe536b3fa72b56fa133fc4527e5636378571bf9512a933b58/diff:/var/lib/docker/overlay2/a0022547a2571620e0e645caea1dac7d993ff45300711cb405b18b27e2e09037/diff:/var/lib/docker/overlay2/76984f88fad0e4464e6ef221a044d5245adeba3e6f719047d621036ce77f79c6/diff:/var/lib/docker/overlay2/0117412b7dba58ffb8043801480d0a9c1f24f5a15fd4ed4e40c128f42c061135/diff:/var/lib/docker/overlay2/2913b224a66f5ba3eb6c9600d0433e81f63404b910576871342d9cbe1a6283d4/diff:/var/lib/docker/overlay2/da7c1e4c80fcb88202e313a07df0663823fffb9016db50855e34850fb071bec9/diff:/var/lib/docker/overlay2/8453e9b0333f82b8ad4280ee390433efcdfa7c10c50b4d3eff22bb8d5da5e997/diff:/var/lib/docker/overlay2/edc101a4332d1a997ba283352f8c5f14bc3a7e439672425e35c81fa2a3327596/diff:/var/lib/docker/overlay2/e7d9d7cd1f5f6c77e60373197d17085f75b71e1f7e29c886f600621258f2d7c0/diff:/var/lib/docker/overlay2/a9e32a06e67667dd13fe38232bb10f6baa352794cb0bc87f0a061c272c5fdc17/diff:/var/lib/docker/overlay2/d7ff8b4b5640fe162f10b0b9b4fa32dc2bc6e312548953874430b373c5c4e2ab/diff:/var/lib/docker/overlay2/d62beae360f2ff1e79b5aed1a55585b1f2e7b912bffe858ae993925421d6f9e1/diff:/var/lib/docker/overlay2/6bcee2acd15a91970d2abe2f214e3f0d801ad18d223f6b890d4a085ba22115f2/diff:/var/lib/docker/overlay2/e6c644392e6a8d717a013ae50bdb580364f4447403cc56cef0ddd256f1e7e899/diff",
                "MergedDir": "/var/lib/docker/overlay2/9ec002ab2bfcc57a140d65ff6e9714f11155d7c31a0f77261d6fa7849d1a826e/merged",
                "UpperDir": "/var/lib/docker/overlay2/9ec002ab2bfcc57a140d65ff6e9714f11155d7c31a0f77261d6fa7849d1a826e/diff",
                "WorkDir": "/var/lib/docker/overlay2/9ec002ab2bfcc57a140d65ff6e9714f11155d7c31a0f77261d6fa7849d1a826e/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "22662bccbabb",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9003/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "CHT_APPLICATION_NAME=projectname",
                "CHT_ENVIRONMENT=dev",
                "CHT_ENABLE_NEWRELIC=false",
                "CHT_ENABLE_SUMOLOGIC=false",
                "CHT_DATABASE_URL=jdbc:postgresql://db:5432/db",
                "CHT_DATABASE_USERNAME=db",
                "CHT_DATABASE_PASSWORD=db",
                "CHT_DATABASE_MAX_POOL_SIZE=3",
                "CHT_PORT=9003",
                "PATH=/app/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto",
                "SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64",
                "SUPERCRONIC=supercronic-linux-amd64",
                "SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e",
                "BUNDLE_SET=deployment true"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "./scripts/run.sh"
            ],
            "Image": "70b00b10fd7ae1d175da435ce32bcfcf_projectname__microservice",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "26e5e9ee9b2e6f724a884f676e1000724c53a4832c522d1515b344b5f1636b9c",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "70b00b10fd7ae1d175da435ce32bcfcf_projectname_",
                "com.docker.compose.project.config_files": "docker-compose.yaml",
                "com.docker.compose.project.working_dir": "/home/david/projects/carbon/projectname",
                "com.docker.compose.service": "microservice",
                "com.docker.compose.version": "1.29.2",
                "desktop.docker.io/wsl-distro": "Ubuntu-18.04"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "b9ba0e00283dda67b9d58069c5865b0ee74efc921e0590d5b5baf9b19a0cd39f",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "9003/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "57174"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/b9ba0e00283d",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "70b00b10fd7ae1d175da435ce32bcfcf_projectname__default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "22662bccbabb",
                        "microservice"
                    ],
                    "NetworkID": "b4681502fb2a5750b091e2978d258acea06fceec75f0028a1fac5637ea6f36ed",
                    "EndpointID": "23175cc2ac7f458cd5a1067af6f7995bd8f005b7597ab77ddb05f9b236d04046",
                    "Gateway": "192.168.0.1",
                    "IPAddress": "192.168.0.2",
                    "IPPrefixLen": 20,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:c0:a8:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]
augi commented 2 years ago

I just want to be sure...are you in the same situation as the original reported, so do you execute Gradle inside WSL?

The issue is that those inspections are the same, regardless of whether you are querying them from Windows or WSL.

So what we actually need is to detect that we are running inside WSL, and use localhost as host then.

Are you aware of any reliable way how to achieve this? I have zero experience with WSL so far :(

dboreham commented 2 years ago

I just want to be sure...are you in the same situation as the original reported, so do you execute Gradle inside WSL?

The issue is that those inspections are the same, regardless of whether you are querying them from Windows or WSL.

So what we actually need is to detect that we are running inside WSL, and use localhost as host then.

Are you aware of any reliable way how to achieve this? I have zero experience with WSL so far :(

Hmm...yes that makes sense since the docker daemon itself is running on Windows native.

Generally WSL2 will always claim it is Linux.

I ran this gradle code:

tasks.register('printOsInfo', Test) {
    description = 'Prints OS Info.'
    group = 'verification'
    String osName = OperatingSystem.current().getName();
    String osVersion = OperatingSystem.current().getVersion();
    println "*** $osName $osVersion was detected."
}

it says:

*** Linux 5.10.43.3-microsoft-standard-WSL2 was detected.
augi commented 2 years ago

Cool! It looks like we could use this. I will prepare a PR tomorrow.

Thank you very much for you assistance! πŸ‘

augi commented 2 years ago

Hello, I'm trying to publish the new version of the plugin but Sonatype is still timeouting, so without success so far 😒

dboreham commented 2 years ago

Hi, wondering if could try again to push this release? Thanks.

augi commented 2 years ago

It is already released, as 0.14.12

dboreham commented 2 years ago

Hmm...my build isn't resolving that version (but it does find 0.4.11). I will dig into where it gets it from...

dboreham commented 2 years ago

Perhaps I should ask: which repo should we expect to find it in? It appears that 0.14.11 is in the gradle plugins repo: https://mvnrepository.com/artifact/com.avast.gradle.docker-compose/com.avast.gradle.docker-compose.gradle.plugin?repo=gradle-plugins but 0.14.12 is not. So far I haven't found 0.14.12 in any repo, but I'm probably holding it wrong...

augi commented 2 years ago

Ah, you're right. There was an issue with publishing to Maven Central and it was handled manually but the publishing to the Gradle Plugin Portal wasn't handled.

I will fix this, and you can use the binaries from Maven Central as described in README in the meantime.

Sorry for the inconvenience.

dboreham commented 2 years ago

Ah, I think I see now what's happening: in my build gradle is configured to use both Maven Central and gradle plugins repos. It presumably checks the plugins repo first and resolves the old version, then never checks Maven Central. I think there's some magic incantation you can use to force it to check the right repo...