You are viewing a plain text version of this content. The canonical link for it is here.
Posted to geb-notifications@groovy.apache.org by cm...@apache.org on 2026/02/28 00:50:16 UTC
(groovy-geb) 05/10: fix container networking.
This is an automated email from the ASF dual-hosted git repository.
cmarcum pushed a commit to branch task/geb-testcontainers
in repository https://gitbox.apache.org/repos/asf/groovy-geb.git
commit 0592330386e481a398cfa8392883c61b7a76db29
Author: Carl Marcum <ca...@codebuilders.net>
AuthorDate: Sun Feb 22 18:57:58 2026 -0500
fix container networking.
---
.../grails/plugin/geb/WebDriverContainerHolder.groovy | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/integration/geb-testcontainers/src/main/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy b/integration/geb-testcontainers/src/main/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
index 0aad65fa..e1b22f45 100644
--- a/integration/geb-testcontainers/src/main/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
+++ b/integration/geb-testcontainers/src/main/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
@@ -424,6 +424,25 @@ class WebDriverContainerHolder {
}
private static String getHostIp() {
+ // In CI environments (container-in-container),
+ // withAccessToHost is disabled and PortForwardingContainer is not used.
+ // Get the actual IP address of this container so other containers can reach it.
+ if (System.getenv('CI')) {
+ try {
+ // Execute hostname -I to get the container's IP address
+ def process = 'hostname -I'.execute()
+ process.waitFor()
+ def ip = process.text.trim().split(/\s+/)[0]
+ if (ip && ip != '127.0.0.1') {
+ return ip
+ }
+ } catch (Exception e) {
+ log.warn('Failed to get container IP via hostname -I', e)
+ }
+ // Fallback to localhost
+ return '127.0.0.1'
+ }
+
try {
PortForwardingContainer.getDeclaredMethod('getNetwork').with {
accessible = true