GitLab CI and hostname resolution in dind mode

I have this job in Gitlab CI:

services:
  -  docker:dind

my_job:
script:
- docker-compose -f ./docker/docker-compose-pipeline.yml up
- docker inspect docker_postgres_1
- telnet localhost 15432

where docker-compose-pipeline.yml is so defined:

version: "2"

services:

    postgres:
        image: gitlab.cdp.it:5001/cdp/postgres:9.5
    volumes:
        - postgres_data:/var/lib/postgresql/data
    ports:
        - "15432:5432"
    environment:
        POSTGRES_PASSWORD: postgres
    privileged: true

The service "postgres" start correctly but it is unreachable, giving the following error:

telnet: can't connect to remote host (172.19.0.2): Operation timed out

The result of "inspect" is:

[
{
   ...
    ],
   ...
        "NetworkMode": "docker_galileo",
        "PortBindings": {
            "5432/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "15432"
                }
            ]
        },
        ...
        "Networks": {
            "docker_galileo": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": [
                    "f399e3c74553",
                    "postgres"
                ],
                "NetworkID": "327beef4f69c2aa34528c387c153e28e604ec47786f672abc802bba0759786a2",
                "EndpointID": "8231aa6ecd4625d0282704a48484eabb00614efc20c49ed92309a907f08f774e",
                "Gateway": "172.19.0.1",
                "IPAddress": "172.19.0.2",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:13:00:02"
            }
        }
    }
}
]

so I tried also with a "telnet 172.19.0.2 15432" without success.

All is working if I start the docker in my linux box host.

Assignee Loading
Time tracking Loading