You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let selenium container have host network mode #143
That should work already. The BrowserWebDriverContainer passes a kwargs object down to the DockerContainer constructor. When we call the start function, that kwargs object is passed to container.run. And according to the docker-py documentation you can pass network as a parameter. So just pass network="host" to the BrowserWebDriverContainer construtor, or any instance of DockerContainer for that matter.
fromselenium.webdriverimportDesiredCapabilitiesfromtestcontainers.seleniumimportBrowserWebDriverContainerwithBrowserWebDriverContainer(capabilities=DesiredCapabilities.CHROME, network="host"):
# here DockerContainer.start is called via __enter__pass
Activity
timbmg commentedon May 13, 2022
That should work already. The
BrowserWebDriverContainerpasses akwargsobject down to theDockerContainerconstructor. When we call thestartfunction, that kwargs object is passed tocontainer.run. And according to the docker-py documentation you can pass network as a parameter. So just passnetwork="host"to theBrowserWebDriverContainerconstrutor, or any instance ofDockerContainerfor that matter.tillahoffmann commentedon Jan 6, 2023
Closing this for now. Feel free to get in touch if the issue persists. Thanks for the insights, @timbmg.