Traefik with Docker on OSX - Gateway Timeout遵循官方指示

时间:2018-02-10 23:40:15

标签: docker docker-compose traefik

  • OSX 10.11.6
  • Docker版本17.12.0-ce,build c97c6d6

按照以下说明操作:https://docs.traefik.io/#test-it

我从默认网络开始:

$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
dc218a8c3b42        bridge              bridge              local
061dad0019b0        docker_gwbridge     bridge              local
25e18684046a        host                host                local
29da4987a368        none                null                local

并没有其他容器:

$ docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

traefik容器很好用:

$ docker-compose up -d
Creating network "testproject_webgateway" with driver "bridge"
Creating testproject_proxy_1 ... done

emilevauge/whoami容器存在小型网络问题:

$ docker-compose up -d
ERROR: Network traefik_webgateway declared as external, but could not be found. Please create the network manually using `docker network create traefik_webgateway` and try again.

所以我手动创建它:

$ docker network create traefik_webgateway
2ee51f3bbd603984a056da6269775d50ab5549fe85c3caf457f4933bf0e97ffe

并重新运行:

$ docker-compose up -d
Creating test_whoami_1 ... done

此时我可以访问Traefik Web UI并查看单个whoami容器:

traefik web ui with single whoami container

最后,我尝试运行curl命令,但收到网关超时错误:

$ curl -H Host:whoami.docker.localhost http://127.0.0.1
Gateway Timeout

traefik容器日志显示以上内容:

time="2018-02-10T23:38:47Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"Proto":"HTTP/1.1","ProtoMajor":1,"ProtoMinor":1,"Header":{"Accept":["*/*"],"User-Agent":["curl/7.50.3"]},"ContentLength":0,"TransferEncoding":null,"Host":"whoami.docker.localhost","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"172.18.0.1:55380","RequestURI":"/","TLS":null}"
time="2018-02-10T23:38:47Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{"Method":"GET","URL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"Proto":"HTTP/1.1","ProtoMajor":1,"ProtoMinor":1,"Header":{"Accept":["*/*"],"User-Agent":["curl/7.50.3"]},"ContentLength":0,"TransferEncoding":null,"Host":"whoami.docker.localhost","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"172.18.0.1:55380","RequestURI":"/","TLS":null}" ForwardURL=http://172.20.0.2:80
time="2018-02-10T23:38:47Z" level=debug msg="vulcand/oxy/forward: begin ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"http","Opaque":"","User":null,"Host":"172.20.0.2:80","Path":"","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"Proto":"HTTP/1.1","ProtoMajor":1,"ProtoMinor":1,"Header":{"Accept":["*/*"],"User-Agent":["curl/7.50.3"]},"ContentLength":0,"TransferEncoding":null,"Host":"whoami.docker.localhost","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"172.18.0.1:55380","RequestURI":"/","TLS":null}"
time="2018-02-10T23:38:47Z" level=debug msg="vulcand/oxy/forward/http: begin ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"http","Opaque":"","User":null,"Host":"172.20.0.2:80","Path":"","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"Proto":"HTTP/1.1","ProtoMajor":1,"ProtoMinor":1,"Header":{"Accept":["*/*"],"User-Agent":["curl/7.50.3"]},"ContentLength":0,"TransferEncoding":null,"Host":"whoami.docker.localhost","Form":null,"PostForm":null,"MultipartForm":null,"Trailer":null,"RemoteAddr":"172.18.0.1:55380","RequestURI":"/","TLS":null}"

我不确定我是否应该在这里做任何其他事情。

我没有具体的答案,但升级到macOS 10.13.x解决了这个问题。

1 个答案:

答案 0 :(得分:0)

我的个人macbook上使用Traefik的问题与我在Ubuntu上运行的办公室的工作站相比也有问题......

这是我的参考...... https://docs.traefik.io/#test-it

首先,您要使用Docker方式使用Traefik start docker compose file 获取也在终端上列出的默认网络。 第二个在你的项目的docker compose文件中,在你的yml文件中添加它。 docker-compose.yml file

还有一件事,请不要忘记在/etc/hosts/文件中添加所需的域名。 my sample /etc/hosts file.

希望,这会有所帮助!