【发布时间】:2021-11-05 03:54:05
【问题描述】:
我遇到了一个
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='chromedriver', port=4444): url: /wd/hub/session 超过最大重试次数(由 NewConnectionError('
: 建立新连接失败:[Errno 111] Connection refused'))
通过 Python 和 Docker 运行 Selenium。
我的连接如下所示:
self.driver = webdriver.Remote(
command_executor='http://chromedriver:4444/wd/hub',
options=options
)
docker-compose 是这样的:
...
chromedriver:
image: selenium/standalone-chrome
ports:
- "4444:4444"
hostname: chromedriver
shm_size: 2g
runner:
image: "kevoooo/twitchfarm-runner:latest"
entrypoint: "python3 /py-scripts/main.py"
healthcheck:
test: python3 /py-scripts/main.py
interval: 30s
timeout: 10s
retries: 5
environment:
- DISPLAY=127.0.0.1
- USER=uname
- PASS=pass
- 2FA_KEY=key
volumes:
- "chrome-data:/saves/google-chrome"
depends_on:
- chromedriver
...
提前致谢!
【问题讨论】:
-
进入 chrome 容器并检查您的 webdriver 是否已启动。我相信它没有。
-
你完全正确!但为什么呢?