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