docker-network-create: Create a network | Docker Commands | Man Pages | ManKier
Description
Creates a new network. The DRIVER
accepts bridge
or overlay
which are the built-in network drivers. If you have installed a third party or your own custom network driver you can specify that DRIVER
here also. If you don’t specify the --driver
option, the command automatically creates a bridge
network for you. When you install Docker Engine it creates a bridge
network automatically. This network corresponds to the docker0
bridge that Engine has traditionally relied on. When you launch a new container with docker run
it automatically connects to this bridge network. You cannot remove this default bridge network but you can create new ones using the network create
command.
$ docker network create -d bridge my-bridge-network
Bridge networks are isolated networks on a single Engine installation. If you want to create a network that spans multiple Docker hosts each running an Engine, you must create an overlay
network. Unlike bridge
networks overlay networks require some pre-existing conditions before you can create one. These conditions are:
- Access to a key-value store. Engine supports Consul, Etcd, and Zookeeper (Distributed store) key-value stores.
- A cluster of hosts with connectivity to the key-value store.
- A properly configured Engine
daemon
on each host in the cluster.
The dockerd
options that support the overlay
network are:
--cluster-store
--cluster-store-opt
--cluster-advertise
To read more about these options and how to configure them, see “Get started with multi-host network” ⟨https://docs.docker.com/engine/userguide/networking/get-started-overlay/⟩.
It is also a good idea, though not required, that you install Docker Swarm on to manage the cluster that makes up your network. Swarm provides sophisticated discovery and server management that can assist your implementation.
Once you have prepared the overlay
network prerequisites you simply choose a Docker host in the cluster and issue the following to create the network:
$ docker network create -d overlay my-multihost-network
Network names must be unique. The Docker daemon attempts to identify naming conflicts but this is not guaranteed. It is the user’s responsibility to avoid name conflicts.