Documentation
¶
Overview ¶
Package tcstart starts test containers on host ports the host has free.
Docker Desktop on macOS publishes a container's port by listening on the host port the VM allocated. The VM allocates host ports in order, and so does macOS its ephemeral ports (the outbound connections to other containers): when they meet, the host port is in use, publishing fails ("bind: address already in use" in the Docker Desktop log), and the container has no host port ("port "3306/tcp" not found"). A port the host itself just handed out and let go is free, and its next ephemeral ports are past it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(req *testcontainers.GenericContainerRequest, publish Publish) error
Apply applies publish to req, a request built by hand.
func Run ¶
func Run[C testcontainers.Container]( ctx context.Context, start func(publish Publish) (C, error), ports ...string, ) (C, error)
Run runs start, which starts a container with publish among its options, publish binding each of ports (every port the container exposes) to a host port the host has free. A container without a host port for one of them, or one whose host port the daemon could not bind (a race lost all the same), is terminated and started again, up to attempts times.
Types ¶
type Publish ¶
type Publish = testcontainers.CustomizeRequestOption
Publish is the option publishing a container's ports (see Run).