Skip to content

getContainerIpAddress always returns localhostΒ #452

@fred777

Description

@fred777

I'm trying to use testcontainers (v1.4.2) for integration testing between a Spring Boot service packed into a GenericContainer and a MysqlContainer.

Unfortunately, getContainerIpAddress will always return "localhost".

Hence, ((MySQLContainer) mysql).getJdbcUrl() will just return garbage: jdbc:mysql://localhost:32821/test

My system: Archlinux x64, Docker version 17.07.0-ce
But same error on colleague's Mac.

The following part of GenericContainer.java doesn't make sense to me

    @Override
    public String getContainerIpAddress() {
        return DockerClientFactory.instance().dockerHostIpAddress();
    }

-> isn't that just returning the mere ip address of the host running docker service?

What I expected here to see is a call returning the IP address of the virtual network interface related to the desired container.... please correct me if I'm wrong...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions