The combined DinD/sidecar networking model breaks non-Testcontainers things which rely on the assumption that 'use of unix socket' == 'networking on localhost'
This change introduces a local TCP socket for the docker daemon, with DOCKER_HOST being set to point to it.
DOCKER_HOST is not set, so Testcontainers and other docker clients use a unix socket to talk to the DinD daemon
Testcontainers automatically detects that it's running in DinD, so uses the correct gateway IP address instead of localhost
Other docker clients with less environment inference try to use localhost to talk to other containers, even though this is incorrect as they are actually 'siblings'
New behaviour:
The DinD docker daemon is now launched listening on both a unix socket and TCP
This plugin determines the correct gateway IP address and sets this in DOCKER_HOST (i.e. like tcp://$GATEWAY_IP:2375)
Testcontainers continues to be happy, and uses TCP to connect to the daemon (and for generated container IP addresses)
Other docker clients can pick up the gateway IP from the DOCKER_HOST environment variable, and treat it as a remote docker daemon
The combined DinD/sidecar networking model breaks non-Testcontainers things which rely on the assumption that 'use of unix socket' == 'networking on localhost'
This change introduces a local TCP socket for the docker daemon, with
DOCKER_HOST
being set to point to it.This changes helps support the DinD side of https://github.com/revolut-engineering/jooq-plugin/issues/3
In summary:
Previous behaviour:
DOCKER_HOST
is not set, so Testcontainers and other docker clients use a unix socket to talk to the DinD daemonNew behaviour:
DOCKER_HOST
(i.e. liketcp://$GATEWAY_IP:2375
)DOCKER_HOST
environment variable, and treat it as a remote docker daemon