mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-423 Docker environment resolve
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
docker run --name cloudbeaver --rm -ti -p 8978:8978 -v /var/cloudbeaver/workspace:/opt/cloudbeaver/workspace dbeaver/cloudbeaver:dev
|
||||
# Detect host machine IP Address (we need this when run in docker container)
|
||||
export CB_LOCAL_HOST_ADDR=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
|
||||
|
||||
docker run --name cloudbeaver --rm -ti -p 8978:8978 --add-host=host.docker.internal:${CB_LOCAL_HOST_ADDR} -v /var/cloudbeaver/workspace:/opt/cloudbeaver/workspace dbeaver/cloudbeaver:dev
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Detect host machine IP Address (we need this when run in docker container)
|
||||
export CB_LOCAL_HOST_ADDR=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
|
||||
|
||||
launcherJar=( server/plugins/org.eclipse.equinox.launcher*.jar )
|
||||
|
||||
echo "Starting Cloudbeaver Server"
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@@ -235,8 +236,8 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
log.debug("\tServer is in configuration mode!");
|
||||
}
|
||||
{
|
||||
log.debug("\tLocal host addresses:");
|
||||
determineLocalAddresses();
|
||||
log.debug("\tLocal host addresses:");
|
||||
for (InetAddress ia : localInetAddresses) {
|
||||
log.debug("\t\t" + ia.getHostAddress() + " (" + ia.getCanonicalHostName() + ")");
|
||||
}
|
||||
@@ -274,6 +275,16 @@ public class CBApplication extends BaseApplicationImpl {
|
||||
// for (InetAddress addr : allMyIps) {
|
||||
// System.out.println("Local addr: " + addr);
|
||||
// }
|
||||
String dockerHostAddress = System.getenv(CBConstants.VAR_HOST_DOCKER_INTERNAL);
|
||||
if (!CommonUtils.isEmpty(dockerHostAddress)) {
|
||||
try {
|
||||
InetAddress dockerAddress = InetAddress.getByName(dockerHostAddress);
|
||||
localInetAddresses.add(dockerAddress);
|
||||
log.debug("\tRun in Docker container (" + dockerAddress + ")");
|
||||
} catch (UnknownHostException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
boolean hasLoopbackAddress = false;
|
||||
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
||||
NetworkInterface intf = en.nextElement();
|
||||
|
||||
@@ -68,4 +68,5 @@ public class CBConstants {
|
||||
public static final String VAR_CB_LOCAL_HOST_ADDR = "CB_LOCAL_HOST_ADDR";
|
||||
|
||||
|
||||
public static final String VAR_HOST_DOCKER_INTERNAL = "host.docker.internal";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user