单个主机上有多个Docker化的angular应用

时间:2019-07-03 14:34:51

标签: angular docker traefik

我正在尝试在单个主机上托管2个具有相同控制台图像的容器,这些容器指向不同的环境,并使用Traefik容器路由至它们。问题是,无法访问第二个容器。我不断收到错误的网关。

使用第二个容器的端口导航到IP失败,但是端口映射配置似乎正常。第二个容器中没有日志。

docker-compose

  console:
    container_name: console
    image: REDACTED
    environment:
      API_URL: "REDACTED-PRD"
    ports:
      - 4200:4200
    labels:
      - traefik.port=4200
      - traefik.frontend.rule=Host:dev.REDACTED.com
  console-prd:
    container_name: console-prd
    image: REDACTED
    environment:
      API_URL: "REDACTED-DEV"
    ports:
      - 4300:4200
    labels:
      - traefik.port=4300
      - traefik.frontend.rule=Host:app.REDACTED.com
  traefik:
    container_name: traefik
    image: traefik:1.7.10-alpine
    ports:
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.toml:/etc/traefik/traefik.toml:Z```

ipaddr:4300 gets bad gateway. Traefik logs:

```time="2019-07-03T14:14:21Z" level=debug msg="Upstream ResponseWriter of type *pipelining.writerWithoutCloseNotify does not implement http.CloseNotifier. Returning dummy channel."
time="2019-07-03T14:14:21Z" level=debug msg="'502 Bad Gateway' caused by: dial tcp 192.168.16.3:4300: connect: connection refused"
time="2019-07-03T14:14:21Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://192.168.16.3:4300, code: 502, Length: 11, duration: 381.832µs tls:version: 303, tls:resume:true, tls:csuite:c02f, tls:server:app.REDACTED.com"
time="2019-07-03T14:14:21Z" level=debug msg="vulcand/oxy/forward/http: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"192.168.16.3:4300\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"app.REDACTED.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"148.78.240.30:50437\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2019-07-03T14:14:21Z" level=debug msg="vulcand/oxy/forward: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"http\",\"Opaque\":\"\",\"User\":null,\"Host\":\"192.168.16.3:4300\",\"Path\":\"\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"app.REDACTED.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"148.78.240.30:50437\",\"RequestURI\":\"/\",\"TLS\":null}"
time="2019-07-03T14:14:21Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"app.REDACTED.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"148.78.240.30:50437\",\"RequestURI\":\"/\",\"TLS\":null}"```

1 个答案:

答案 0 :(得分:0)

traefik端口在标签中也应为4200。 Traefik没有使用已发布的端口