【问题标题】:Domain resolves on host machine but not inside docker container域在主机上解析,但不在 docker 容器内
【发布时间】:2016-08-25 01:24:39
【问题描述】:

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

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

当我在 selenium 容器上运行 VNC 时,打开容器内的 chrome 浏览器并输入 www.example.localhost:3000 它无法解析域。但是,当我运行 wget www.example.localhost:3000 时,它会很好地获取 index.html 文件。知道我做错了什么吗?

【问题讨论】:

    标签: node.js selenium docker protractor docker-compose


    【解决方案1】:

    结果在谷歌浏览器中,任何以localhost 结尾的域都解析为 127.0.0.1,无论您有什么 DNS 设置。将域从 .localhost 更改为 .dev 可以解决此问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-29
      • 1970-01-01
      • 2017-09-14
      相关资源
      最近更新 更多