zoukankan      html  css  js  c++  java
  • docker exec -it nginx ping app

    参考

    https://www.cnblogs.com/jsonhc/p/7823286.html

    执行

    docker network ls
    NETWORK ID          NAME                         DRIVER              SCOPE
     3128bb034163        bridge                       bridge              local
     0acd8b6f9ff5        host                         host                local
     d8f63fd8ab0a        none                         null                local
     9222aa01dbf5        ***s-api_***apin             bridge              local
     93992c4bdd0d        travellist-demo_travellist   bridge              local

    可以看出在启动服务的时候创建了服务级别的网络***s-api_***apin

    t****@laravel-docker-t****:~/***api/***s-api$ docker exec -it ***api-nginx ping ***api-app
    PING ***api-app (172.21.0.4): 56 data bytes
    64 bytes from 172.21.0.4: seq=0 ttl=64 time=0.142 ms
    64 bytes from 172.21.0.4: seq=1 ttl=64 time=0.128 ms
    64 bytes from 172.21.0.4: seq=2 ttl=64 time=0.158 ms
    64 bytes from 172.21.0.4: seq=3 ttl=64 time=0.105 ms
    64 bytes from 172.21.0.4: seq=4 ttl=64 time=0.152 ms
    64 bytes from 172.21.0.4: seq=5 ttl=64 time=0.137 ms
    64 bytes from 172.21.0.4: seq=6 ttl=64 time=0.164 ms
    64 bytes from 172.21.0.4: seq=7 ttl=64 time=0.133 ms
    64 bytes from 172.21.0.4: seq=8 ttl=64 time=0.128 ms
    64 bytes from 172.21.0.4: seq=9 ttl=64 time=0.163 ms
    64 bytes from 172.21.0.4: seq=10 ttl=64 time=0.148 ms
    64 bytes from 172.21.0.4: seq=11 ttl=64 time=0.148 ms
    64 bytes from 172.21.0.4: seq=12 ttl=64 time=0.185 ms
    ^C
    --- ***api-app ping statistics ---
    13 packets transmitted, 13 packets received, 0% packet loss
    round-trip min/avg/max = 0.105/0.145/0.185 ms
    t****@laravel-docker-t****:~/***api/***s-api$

    服务nginx【***api-nginx】和php【***api-app】在网络***s-api_***apin实现了互联通信

    在nginx【***api-nginx】服务中能够访问php【***api-app】的服务,

    在compose编排中级别的访问是对service级别的访问,所以在nginx服务配置文件中对应的php能够实现,不会导致nginx启动失败

    --links也是能够使得服务间进行访问的,但是官方现在不推荐—links links和depends_on搭配使用,确定先后启动顺序及相互间通讯。还有expose。external_links

  • 相关阅读:
    Apache-Shiro
    Linux下的Nginx安装
    Linux安装Redis
    Linux安装ftp组件vsftpd
    Spring笔记(二)
    Spring笔记(一)
    MySQL事务
    rocketMQ基本理解
    2018面试题小结
    v-if和v-show
  • 原文地址:https://www.cnblogs.com/dzkjz/p/13298661.html
Copyright © 2011-2022 走看看