zoukankan      html  css  js  c++  java
  • [Docker] Driver Bridge network for linking containers

    In previous post we have seen how to link two container together by using `--link`:

    # docker run -d --name my-mongodb mongo
    # docker run -d -p 3000:3000 --link my-mongodb:mongodb --name nodeapp danwahlin/node

    In this poist, we are going to see how to create brige network, and link contianer inside network.

    First, we can create a network:

    docker network create --driver bridge isolated_network

    We can inspect our network:

    docker network inspect isolated_network

    Once we add container into network, this command is helpful.

    Run the MongoDB container and link it into network, also give it a name 'mongodb'

    docker run -d --net=isolated_network --name mongodb mongo

    Run the nodejs container and link it to network, also give it a name 'nodeapp':

    docker run -d -p 3000:3000 --net=isolated_network --name nodeapp danwalin/node

    Linking container into network is useful for tow or three containers, but once we have more containers, it is not convenient to write so many command lines to get job done. Instead we can use Docker Compose for this task.

  • 相关阅读:
    HDU 5937 Equation
    HDU 5936 Difference
    hdu 4348 To the moon
    SPOJ QTREE Query on a tree
    HDU 3966 Aragorn's Story
    Codeforces 733F Drivers Dissatisfaction
    道良心题
    dp小总结
    数据结构
    数学相关(偏数学向题目的集中地)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/10659062.html
Copyright © 2011-2022 走看看