gpt4 book ai didi

azure - 无法连接到在容器应用程序服务上运行的 selenium/standalone-chrome docker 容器

转载 作者:行者123 更新时间:2023-12-03 03:39:02 52 4
gpt4 key购买 nike

我在本地测试了一个 docker compose,其中有一个 selenium/standalone-chrome 容器和一个 dotnet core 容器,并实现了自动化 UI 测试。使用 docker compose 文件中的主机名设置,我可以正确连接并成功运行自动化测试。

现在我尝试将它们部署到 Azure Web App for Container,但 dotnet core 应用程序出现错误,指出它无法连接到其他容器:

2022-04-29T19:22:26.175504823Z Unhandled exception. OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://chrome:4444/wd/hub/session. The exception message was: Name or service not known
2022-04-29T19:22:26.175552225Z ---> System.Net.Http.HttpRequestException: Name or service not known
2022-04-29T19:22:26.175558125Z ---> System.Net.Sockets.SocketException (0xFFFDFFFF): Name or service not known
2022-04-29T19:22:26.175562626Z at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
2022-04-29T19:22:26.175566926Z --- End of inner exception stack trace ---
2022-04-29T19:22:26.175571026Z at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
2022-04-29T19:22:26.175575226Z at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
2022-04-29T19:22:26.175579526Z at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
2022-04-29T19:22:26.175583826Z at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
2022-04-29T19:22:26.175588027Z at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
2022-04-29T19:22:26.175592327Z at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
2022-04-29T19:22:26.175596627Z at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
2022-04-29T19:22:26.175601027Z at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
2022-04-29T19:22:26.175605227Z at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
2022-04-29T19:22:26.175615128Z --- End of inner exception stack trace ---
2022-04-29T19:22:26.175619328Z at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
2022-04-29T19:22:26.175623528Z at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
2022-04-29T19:22:26.175639629Z at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
2022-04-29T19:22:26.175643929Z at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
2022-04-29T19:22:26.175648529Z at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
2022-04-29T19:22:26.175652229Z at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout)
2022-04-29T19:22:26.175656029Z at SparefootScrape.Program.StartDriver() in /src/Program.cs:line 99
2022-04-29T19:22:26.175659630Z at SparefootScrape.Program.Main(String[] args) in /src/Program.cs:line 39
2022-04-29T19:22:26.176521765Z at SparefootScrape.Program.<Main>(String[] args)

我还尝试了 localhost,而不是使用 docker compose 文件中的主机名分配的“chrome”值,但它也不起作用。

有什么建议吗?

这是我的 docker-compose:

version: "1.0"
services:
scrape:
image: "xxxxxx.azurecr.io/yyyyy:4.0"
stdin_open: true # docker run -i
tty: true # docker run -t
shm_size: '2gb'
restart: always
depends_on:
- chrome

selenium:
image: "selenium/standalone-chrome:latest"
container_name: "chrome"
hostname: chrome
shm_size: '2gb'
restart: always
ports:
- "4444:4444"

最佳答案

我将其用于反转 docker-compose.yml 上的定义并重命名服务:

version: "1.0"
services:

chrome:
image: "selenium/standalone-chrome:latest"
container_name: "chrome"
hostname: chrome
shm_size: '2gb'
restart: always
ports:
- "4444:4444"

scrape:
image: "xxxxxx.azurecr.io/yyyyy:4.0"
stdin_open: true # docker run -i
tty: true # docker run -t
shm_size: '2gb'
restart: always
depends_on:
- chrome

关于azure - 无法连接到在容器应用程序服务上运行的 selenium/standalone-chrome docker 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72062876/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com