加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

可以从curl访问docker服务,但不能从邮递员/ chrome访问

发布时间:2020-12-14 01:24:24 所属栏目:Linux 来源:网络整理
导读:我正在做Docker入门指南: https://docs.docker.com/get-started/part3/#recap-and-cheat-sheet-optional 泊坞窗,compose.yml: version: "3"services: web: # replace username/repo:tag with your name and image details image: username/repo:tag deploy
我正在做Docker入门指南: https://docs.docker.com/get-started/part3/#recap-and-cheat-sheet-optional

泊坞窗,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

<h3>Hello World!</h3><b>Hostname:</b> 1532cae6e06f<br/>....

但是我无法通过访问http:// localhost:80(它永远加载)从chrome或邮递员访问它.为什么以及如何解决它?

更新19/10/17:

我可以在浏览器中访问我的服务:http://192.168.1.68:80.
它是领导节点的地址(也是我真机的IP).

但是为什么我不能从localhost那里做呢?

解决方法

看到卷曲-4 ……让我怀疑这是一个ipv6问题.如果没有为ipv6配置本地计算机,并且localhost在hosts文件中引用了ipv6地址,则对localhost的调用将挂起.

解决方法相当简单,在您的网址中转到127.0.0.1而不是localhost.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读