Skip to content

Commit

Permalink
Use gateway address when docker network is host
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Oct 26, 2023
1 parent 12e6af9 commit 8a5b728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
with:
timeout_minutes: 30
max_attempts: 3
command: mvn -B test -Dtest=!Record*
command: mvn -B test -Dtest=!Docker*,!Record*
- name: Run tests on Windows
if: matrix.os == 'windows-latest'
uses: nick-fields/retry@v2.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,10 @@ public DockerContainer startBrowserContainer(String dockerImage,

String containerId = startContainer(browserContainer);
browserContainer.setContainerId(containerId);
String browserHost = getHost(containerId, network);
String gateway = getGateway(containerId, network);
browserContainer.setGateway(gateway);
String browserHost = isHost(network) ? gateway
: getHost(containerId, network);
String browserPort = isHost(network) ? dockerBrowserPort
: getBindPort(containerId, dockerBrowserPort + "/tcp");
String browserUrlFormat = "http://%s:%s/";
Expand All @@ -680,8 +683,6 @@ public DockerContainer startBrowserContainer(String dockerImage,

String browserUrl = format(browserUrlFormat, browserHost, browserPort);
browserContainer.setContainerUrl(browserUrl);
String gateway = getGateway(containerId, network);
browserContainer.setGateway(gateway);
String address = getAddress(containerId, network);
browserContainer.setAddress(address);
log.trace("Browser remote URL {}", browserUrl);
Expand Down Expand Up @@ -725,7 +726,7 @@ public DockerContainer startRecorderContainer(String dockerImage,

// envs
List<String> envs = new ArrayList<>();
String browserAddress = isHost(network) ? DockerHost.DEFAULT_ADDRESS
String browserAddress = isHost(network) ? browserContainer.getGateway()
: browserContainer.getAddress();
envs.add("BROWSER_CONTAINER_NAME=" + browserAddress);
Path recordingPath = getRecordingPath(browserContainer);
Expand Down

0 comments on commit 8a5b728

Please sign in to comment.