Skip to content

Commit

Permalink
fix getContainerIP
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Sep 29, 2024
1 parent 30cb1fb commit 96264cb
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.oceanbase.connector.flink;

import com.github.dockerjava.api.model.ContainerNetwork;
import org.junit.ClassRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -83,12 +84,13 @@ public OceanBaseProxyContainer createOdpContainer(String password) {

private static String getContainerIP(GenericContainer<?> container) {
String ip =
container
.getContainerInfo()
.getNetworkSettings()
.getNetworks()
.get(NETWORK.getId())
.getIpAddress();
container.getContainerInfo().getNetworkSettings().getNetworks().values().stream()
.findFirst()
.map(ContainerNetwork::getIpAddress)
.orElseThrow(
() ->
new RuntimeException(
"Can't get IP address of container: " + container));
LOG.info("Docker image: {}, IP: {}", container.getDockerImageName(), ip);
return ip;
}
Expand Down

0 comments on commit 96264cb

Please sign in to comment.