[英]Domain resolves on host machine but not inside docker container
我有两个容器,一个运行启动量角器的Node.js进程,另一个运行独立的Selenium容器。 该文件如下所示:
version: '2'
services:
www.example.localhost:
build: .
depends_on:
- selenium
dns_search:
- static.example.localhost
extra_hosts:
- "static.example.localhost:127.0.0.1"
ports:
- "3000:3000"
- "4000:4000"
volumes:
- ./src:/code/src
- ./api:/code/api
entrypoint: "npm run"
command: "test:e2e"
selenium:
dns_search:
- selenium.example.localhost
image: selenium/standalone-chrome-debug:2.52.0
environment:
no_proxy: localhost
volumes:
- /dev/urandom:/dev/random
ports:
- "4444:4444"
- "6900:5900"
www.example.localhost
运行protractor,然后使用protractor.config.js中的以下行连接到硒容器:
seleniumAddress: "http://selenium:4444/wd/hub",
directConnect: false,
当我在硒容器上运行VNC时,打开容器内的chrome浏览器并输入www.example.localhost:3000
它无法解析域。 但是,当我运行wget www.example.localhost:3000
它会得到index.html文件。 知道我在做什么错吗?
在Google Chrome浏览器中,无论您使用什么DNS设置,任何以localhost
结尾的域都将解析为127.0.0.1。 将域从.localhost
更改为.dev
.localhost
进行修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.