github.com/vincentwoo/docker@v0.7.3-0.20160116130405-82401a4b13c0/man/docker-network-create.1.md (about)

     1  % DOCKER(1) Docker User Manuals
     2  % Docker Community
     3  % OCT 2015
     4  # NAME
     5  docker-network-create - create a new network
     6  
     7  # SYNOPSIS
     8  **docker network create**
     9  [**--aux-address**=*map[]*]
    10  [**-d**|**--driver**=*DRIVER*]
    11  [**--gateway**=*[]*]
    12  [**--help**]
    13  [**--internal**]
    14  [**--ip-range**=*[]*]
    15  [**--ipam-driver**=*default*]
    16  [**--ipam-opt**=*map[]*]
    17  [**-o**|**--opt**=*map[]*]
    18  [**--subnet**=*[]*]
    19  NETWORK-NAME
    20  
    21  # DESCRIPTION
    22  
    23  Creates a new network. The `DRIVER` accepts `bridge` or `overlay` which are the
    24  built-in network drivers. If you have installed a third party or your own custom
    25  network driver you can specify that `DRIVER` here also. If you don't specify the
    26  `--driver` option, the command automatically creates a `bridge` network for you.
    27  When you install Docker Engine it creates a `bridge` network automatically. This
    28  network corresponds to the `docker0` bridge that Engine has traditionally relied
    29  on. When launch a new container with  `docker run` it automatically connects to
    30  this bridge network. You cannot remove this default bridge network but you can
    31  create new ones using the `network create` command.
    32  
    33  ```bash
    34  $ docker network create -d bridge my-bridge-network
    35  ```
    36  
    37  Bridge networks are isolated networks on a single Engine installation. If you
    38  want to create a network that spans multiple Docker hosts each running an
    39  Engine, you must create an `overlay` network. Unlike `bridge` networks overlay
    40  networks require some pre-existing conditions before you can create one. These
    41  conditions are:
    42  
    43  * Access to a key-value store. Engine supports Consul, Etcd, and Zookeeper (Distributed store) key-value stores.
    44  * A cluster of hosts with connectivity to the key-value store.
    45  * A properly configured Engine `daemon` on each host in the cluster.
    46  
    47  The `docker daemon` options that support the `overlay` network are:
    48  
    49  * `--cluster-store`
    50  * `--cluster-store-opt`
    51  * `--cluster-advertise`
    52  
    53  To read more about these options and how to configure them, see ["*Get started
    54  with multi-host
    55  network*"](https://www.docker.com/engine/userguide/networking/get-started-overlay.md).
    56  
    57  It is also a good idea, though not required, that you install Docker Swarm on to
    58  manage the cluster that makes up your network. Swarm provides sophisticated
    59  discovery and server management that can assist your implementation.
    60  
    61  Once you have prepared the `overlay` network prerequisites you simply choose a
    62  Docker host in the cluster and issue the following to create the network:
    63  
    64  ```bash
    65  $ docker network create -d overlay my-multihost-network
    66  ```
    67  
    68  Network names must be unique. The Docker daemon attempts to identify naming
    69  conflicts but this is not guaranteed. It is the user's responsibility to avoid
    70  name conflicts.
    71  
    72  ## Connect containers
    73  
    74  When you start a container use the `--net` flag to connect it to a network.
    75  This adds the `busybox` container to the `mynet` network.
    76  
    77  ```bash
    78  $ docker run -itd --net=mynet busybox
    79  ```
    80  
    81  If you want to add a container to a network after the container is already
    82  running use the `docker network connect` subcommand.
    83  
    84  You can connect multiple containers to the same network. Once connected, the
    85  containers can communicate using only another container's IP address or name.
    86  For `overlay` networks or custom plugins that support multi-host connectivity,
    87  containers connected to the same multi-host network but launched from different
    88  Engines can also communicate in this way.
    89  
    90  You can disconnect a container from a network using the `docker network
    91  disconnect` command.
    92  
    93  ## Specifying advanced options
    94  
    95  When you create a network, Engine creates a non-overlapping subnetwork for the
    96  network by default. This subnetwork is not a subdivision of an existing network.
    97  It is purely for ip-addressing purposes. You can override this default and
    98  specify subnetwork values directly using the the `--subnet` option. On a
    99  `bridge` network you can only create a single subnet:
   100  
   101  ```bash
   102  docker network create -d bridge --subnet=192.168.0.0/16 br0
   103  ```
   104  Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address` options.
   105  
   106  ```bash
   107  network create --driver=bridge --subnet=172.28.0.0/16 --ip-range=172.28.5.0/24 --gateway=172.28.5.254 br0
   108  ```
   109  
   110  If you omit the `--gateway` flag the Engine selects one for you from inside a
   111  preferred pool. For `overlay` networks and for network driver plugins that
   112  support it you can create multiple subnetworks.
   113  
   114  ```bash
   115  docker network create -d overlay
   116    --subnet=192.168.0.0/16 --subnet=192.170.0.0/16
   117    --gateway=192.168.0.100 --gateway=192.170.0.100
   118    --ip-range=192.168.1.0/24
   119    --aux-address a=192.168.1.5 --aux-address b=192.168.1.6
   120    --aux-address a=192.170.1.5 --aux-address b=192.170.1.6
   121    my-multihost-network
   122  ```
   123  Be sure that your subnetworks do not overlap. If they do, the network create fails and Engine returns an error.
   124  
   125  ### Network internal mode
   126  
   127  By default, when you connect a container to an `overlay` network, Docker also connects a bridge network to it to provide external connectivity.
   128  If you want to create an externally isolated `overlay` network, you can specify the `--internal` option.
   129  
   130  # OPTIONS
   131  **--aux-address**=map[]
   132    Auxiliary ipv4 or ipv6 addresses used by network driver
   133  
   134  **-d**, **--driver**=*DRIVER*
   135    Driver to manage the Network bridge or overlay. The default is bridge.
   136  
   137  **--gateway**=[]
   138    ipv4 or ipv6 Gateway for the master subnet
   139  
   140  **--help**
   141    Print usage
   142  
   143  **--internal**
   144    Restricts external access to the network
   145  
   146  **--ip-range**=[]
   147    Allocate container ip from a sub-range
   148  
   149  **--ipam-driver**=*default*
   150    IP Address Management Driver
   151  
   152  **--ipam-opt**=map[]
   153    Set custom IPAM plugin options
   154  
   155  **-o**, **--opt**=map[]
   156    Set custom network plugin options
   157  
   158  **--subnet**=[]
   159    Subnet in CIDR format that represents a network segment
   160  
   161  # HISTORY
   162  OCT 2015, created by Mary Anthony <mary@docker.com>