我正在做docker入门指南: docs.docker/get-started/part3/#recap-and-cheat-sheet-optional
I'm doing the docker getting started guide: docs.docker/get-started/part3/#recap-and-cheat-sheet-optional
docker -compose.yml:
version: "3" services: web: # replace username/repo:tag with your name and image details image: username/repo:tag deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: condition: on-failure ports: - "80:80" networks: - webnet networks: webnet:我通过运行 docker stack deploy -c docker-compose.yml getstartedlab 部署了我的应用程序。 然后从curl上访问我的服务,它可以正常工作 curl -4 http:// localhost
I deployed my app by running docker stack deploy -c docker-compose.yml getstartedlab. Then Accessing my service from curl which working fine curl -4 localhost
<h3>Hello World!</h3><b>Hostname:</b> 1532cae6e06f<br/>....但是我无法从Chrome或邮递员访问它通过转到 http:// localhost:80 (它将永远加载)。为什么以及如何解决它?
But I can't access it from chrome or postman by going to localhost:80 (it loads forever). Why and how can I fix it?
我可以从以下浏览器访问我的服务: 192.168.1.68:80 。 这是领导节点的地址(也是我的真实机器的IP。)。
I can access my service in the browser from: 192.168.1.68:80 . It is the address of the leader node (which is the ip of my real machine also..).
但是为什么我不能
推荐答案看到 curl -4 ... 使我怀疑这是ipv6问题。如果未为ipv6配置本地计算机,并且localhost在hosts文件中引用了ipv6地址,则对localhost的调用将挂起。
Seeing the curl -4 ... makes me suspect this is an ipv6 issue. If your local machine isn't configured for ipv6 and localhost has a reference to the ipv6 address in the hosts file, then calls to localhost will hang.
很简单,在您的网址中转到 127.0.0.1 而不是 localhost 。
The workaround is rather simple, go to 127.0.0.1 instead of localhost in your urls.
更多推荐
可以通过curl访问docker服务,但不能从postman / chrome访问
发布评论