zoukankan      html  css  js  c++  java
  • 记录下(同一个计算机)多个容器 dockr bridge(桥接) docker-compose 配置

    首先先配置好桥接容器(mysql_bridge 为一个桥接网络,A容器可以在此暴露A容器的服务接口,让B容器使用A容器的服务)

    docker network mysql_bridge

    直接上

    version: '3'
    
    services:
      mysql:
        container_name: mysql
        image: mysql:5.7.21
        environment:
          MYSQL_ROOT_PASSWORD: root
        volumes:
          - ./data/mysql:/var/lib/mysql
        expose:
          - 3306
        ports:
          - 3306:3306
        networks:
          - mysql_bridge
        restart: on-failure
    
      redis:
        container_name: redis
        image: redis:4.0.6
        expose:
          - 6379
        ports:
          - 6379:6379
        volumes:
          - ./data/redis:/usr/share/redis/data:rw
        networks:
          - redis_bridge
    
      mongo:
        container_name: mongo
        image: mongo:4.0.9
        volumes:
          - ./data/mongo:/data/db
        expose:
          - 27017
        ports:
          - 27017:27017
        networks:
          - mongo_bridge
        restart: on-failure
    
    networks:
      mysql_bridge:
        external: true
      redis_bridge:
        external: true
      mongo_bridge:
        external: true

     容器使用桥接例子:

    version: '3'
    
    services:
      web:
        container_name: web
        build:
          context: ./
        volumes:
          - ./:/var/www
        ports:
          - 81:80
        external_links:
            - mysql
            - redis
        restart: on-failure
        networks:
          - mysql_bridge
          - redis_bridge
    
    
    networks:
      mysql_bridge:
        external: true
      redis_bridge:
        external: true
  • 相关阅读:
    poj1019——log10求位数
    poj2084——卡特兰数
    hdoj1023——卡特兰数
    poj1496——组合数学
    poj1850——组合数学
    bestcoder#29 1002 矩阵连乘快速幂解fib数列
    bestcoder#28 1002 dfs
    poj1458——dp,lcs
    hduoj1106
    codeforces#296div2_b 字符串,图
  • 原文地址:https://www.cnblogs.com/zjhblogs/p/10775667.html
Copyright © 2011-2022 走看看