withExtraHost method

GenericContainer withExtraHost(
  1. String host,
  2. String address
)

Adds host with address to the container's hosts file; the address host-gateway is the machine the daemon runs on (withExtraHost('host.docker.internal', 'host-gateway') makes that name work on Linux as it does on Docker Desktop).

Testcontainers (Java): withExtraHost(host, address).

Implementation

GenericContainer withExtraHost(String host, String address) {
  _extraHosts.add('$host:$address');
  return this;
}