我想在DockerCompose上使用Selenium和Ruby,在另一台服务器上使用chrome,但是我得到了一个错误。
以下是各种代码和错误。
- DockerCompose.yml
version: "3"
services:
ruby:
build:
context: .
dockerfile: RubyDockerFile
ports:
- "3000:3000"
tty: true
chrome:
image: selenium/standalone-chrome:4.0.0-beta-3-20210426
container_name: chrome
volumes:
- /dev/shm:/dev/shm
ports:
- 4444:4444
- 5900:5900
- 7900:7900
- RubyDocker中的Ruby代码
driver = Selenium::WebDriver.for :remote, url: 'http://chrome:4444', desired_capabilities: :chrome
- 错误
Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>
/usr/local/bundle/gems/rack-mini-profiler-2.3.1/lib/patches/net_patches.rb:19:in `block in request_with_mini_profiler'
/usr/local/bundle/gems/rack-mini-profiler-2.3.1/lib/mini_profiler/profiling_methods.rb:46:in `step'
/usr/local/bundle/gems/rack-mini-profiler-2.3.1/lib/patches/net_patches.rb:18:in `request_with_mini_profiler'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:102:in `create_session'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:56:in `handshake'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/driver.rb:39:in `initialize'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:58:in `new'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:58:in `for'
/usr/local/bundle/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in `for'
/hoge.rake:9:in `block (2 levels) in <main>'
2条答案
按热度按时间fnvucqvd1#
如果延长超时时间,现在就可以连接了。
ca1c2owp2#
在我们的案例中,这是Docker-in-Docker下MTU的一个问题(我们的CI平台如何工作)。
修复方法是通过向CI中使用的
docker-compose.yml
添加以下内容来降低MTU:我的同事在这里写了这个:https://chen.do/docker-in-docker-dind-mtu-fix-for-docker-compose/
实际的症状可能是多种多样的,令人惊讶的,但当我们打开一个内部Docker容器中的shell时,我们证实了这一点,我们能够ping和
curl https://example.com
,但某些请求将无限期地挂起(通常在TLS协商时)。那边