palantir/docker-compose-rule

inFormat method on DockerPort gives incorrect results when tests are run on docker network

mdotson opened this issue · 0 comments

Given a docker-compose file that externally connects to the same network as the tests are being run, the DockerPort#inFormat method will replace $HOST with localhost when it should return the container name.

Example: tests are running in a docker container with the network my-pre-existing-network with the following docker-compose.yml (this docker-compose file will connect the services in it on to the same network as the container running the tests):

version: "3"
networks:
  default:
    external:
      name: my-pre-existing-network
services:
  db:
    image: postgres
    expose:
    - "5432"

When one calls rule.containers().container("postgres").inFormat("$HOST"), it returns localhost on linux and docker-for-mac when in fact the container is not reachable on localhost, but instead at postgres since it is on the same network as the tests.