Skip to content

Commit

Permalink
Add support for docker desktop host mode out of beta
Browse files Browse the repository at this point in the history
Signed-off-by: Dramelac <[email protected]>
  • Loading branch information
Dramelac committed Aug 31, 2024
1 parent 35ea87e commit 8ddbbd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 9 additions & 1 deletion exegol/config/EnvInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions exegol/model/ContainerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8ddbbd6

Please sign in to comment.