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