From 8ddbbd63b8c8b7d40a6e8ede880d46f1e90ada7f Mon Sep 17 00:00:00 2001 From: Dramelac Date: Sat, 31 Aug 2024 19:42:17 +0200 Subject: [PATCH] Add support for docker desktop host mode out of beta Signed-off-by: Dramelac --- exegol/config/EnvInfo.py | 10 +++++++++- exegol/model/ContainerConfig.py | 6 ++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/exegol/config/EnvInfo.py b/exegol/config/EnvInfo.py index 8b9842fb..6c4b6b51 100644 --- a/exegol/config/EnvInfo.py +++ b/exegol/config/EnvInfo.py @@ -226,7 +226,15 @@ def isHostNetworkAvailable(cls) -> bool: elif cls.isOrbstack(): return True elif cls.isDockerDesktop(): - res = cls.getDockerDesktopSettings().get('hostNetworkingEnabled', False) + res = cls.getDockerDesktopSettings().get('hostNetworkingEnabled') + if res is None: + logger.warning("Host network mode for Docker Desktop is not available, you need to upgrade Docker Desktop to enable it!") + elif not res: + logger.warning( + "Docker desktop now supports host network mode. However, this mode is currently [red]disabled[/red]. You need to manually change the configuration in your Docker Desktop settings to support host network sharing with Exegol.") + if not res: + logger.info("To share network ports (without host network) between the host and exegol, use the [bright_blue]--port[/bright_blue] parameter.") + logger.verbose("Official doc: https://docs.docker.com/network/drivers/host/#docker-desktop") return res if res is not None else False logger.warning("Unknown or not supported environment for host network mode.") return False diff --git a/exegol/model/ContainerConfig.py b/exegol/model/ContainerConfig.py index 1075b1ed..2098d914 100644 --- a/exegol/model/ContainerConfig.py +++ b/exegol/model/ContainerConfig.py @@ -945,12 +945,10 @@ def setNetworkMode(self, network: Union[ExegolNetworkMode, str] = ExegolNetworkM net_mode = self.__fallback_network_mode if EnvInfo.isDockerDesktop(): if not EnvInfo.isHostNetworkAvailable(): - logger.warning("Host network mode for Docker desktop (Windows & macOS) is not available.") - logger.verbose("Official doc: https://docs.docker.com/network/drivers/host/#docker-desktop") - logger.info("To share network ports between the host and exegol, use the [bright_blue]--port[/bright_blue] parameter.") net_mode = self.__fallback_network_mode else: - logger.warning("Docker desktop host network mode is enabled but in beta. Everything might not work as you expect.") + logger.warning("The network mode of the Docker desktop host has its limitations. It may not work as expected.") + logger.verbose("More information from the official documentation of Docker Desktop: https://docs.docker.com/network/drivers/host/#docker-desktop") self.__networks.clear() if type(net_mode) is str or net_mode != ExegolNetworkMode.disable: