温馨提示:本文翻译自stackoverflow.com,查看原文请点击:docker - Multiple Dockerized angular apps on a single host

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

发布于 2020-03-27 11:22:04

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

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

码头工人组成

  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}"```

查看更多

查看更多

提问者
Nick K
被浏览
117
Manuel Polacek 2019-07-03 22:40

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览