域在主机上parsing,但不在docker容器内

我有两个容器,一个运行启动量angular器的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运行量angular器,然后通过protractor.config.js中的这些行连接到selenium容器:

 seleniumAddress: "http://selenium:4444/wd/hub", directConnect: false, 

当我在Selenium容器上运行VNC时,打开容器中的chrome浏览器并键入www.example.localhost:3000它无法parsing域。 但是,当我运行wget www.example.localhost:3000它得到的index.html文件就好了。 任何想法我做错了什么?

在Chrome浏览器中,无论您使用哪种DNS设置,任何以localhost结尾的域都会parsing为127.0.0.1。 将域从.localhost更改为.dev修复它。