@@ -60,3 +60,42 @@ req := ContainerRequest{
6060 WaitingFor : wait.ForExposedPort ().SkipInternalCheck (),
6161}
6262```
63+
64+ ## Skipping the external check
65+
66+ _ Testcontainers for Go_ checks if the container is listening to the port externally (outside of container,
67+ from the host where _ Testcontainers for Go_ is used) before returning the control to the caller.
68+
69+ But there are cases where this external check is not needed.
70+ In this case, the ` wait.ForListeningPort.SkipExternalCheck ` can be used to skip the external check.
71+
72+ ``` golang
73+ req := ContainerRequest {
74+ Image : " nginx:alpine" ,
75+ // Do not check port 80 externally, check it internally only
76+ WaitingFor : wait.ForListeningPort (" 80/tcp" ).SkipExternalCheck (),
77+ }
78+ ```
79+
80+ If there is a need to wait only for completion of container port mapping (which doesn't happen immediately after container is started),
81+ then both internal and external checks can be skipped:
82+
83+ ``` golang
84+ req := ContainerRequest {
85+ Image : " nginx:alpine" ,
86+ ExposedPorts : []string {" 80/tcp" },
87+ // Wait only for completion of port 80 mapping (from container runtime perspective), do not connect to 80 port
88+ WaitingFor : wait.ForListeningPort (" 80/tcp" ).SkipInternalCheck ().SkipExternalCheck (),
89+ }
90+ ```
91+
92+ Alternatively, ` wait.ForMappedPort ` can be used:
93+
94+ ``` golang
95+ req := ContainerRequest {
96+ Image : " nginx:alpine" ,
97+ ExposedPorts : []string {" 80/tcp" },
98+ // Wait only for completion of port 80 mapping (from container runtime perspective), do not connect to 80 port
99+ WaitingFor : wait.ForMappedPort (" 80/tcp" ),
100+ }
101+ ```
0 commit comments