github.com/slava-ustovytski/docker@v1.8.2-rc1/experimental/networking.md (about) 1 # Experimental: Networking and Services 2 3 In this feature: 4 5 - `network` and `service` become first class objects in the Docker UI 6 - one can now create networks, publish services on that network and attach containers to the services 7 - Native multi-host networking 8 - `network` and `service` objects are globally significant and provides multi-host container connectivity natively 9 - Inbuilt simple Service Discovery 10 - With multi-host networking and top-level `service` object, Docker now provides out of the box simple Service Discovery for containers running in a network 11 - Batteries included but removable 12 - Docker provides inbuilt native multi-host networking by default & can be swapped by any remote driver provided by external plugins. 13 14 This is an experimental feature. For information on installing and using experimental features, see [the experimental feature overview](README.md). 15 16 ## Using Networks 17 18 Usage: docker network [OPTIONS] COMMAND [OPTIONS] [arg...] 19 20 Commands: 21 create Create a network 22 rm Remove a network 23 ls List all networks 24 info Display information of a network 25 26 Run 'docker network COMMAND --help' for more information on a command. 27 28 --help=false Print usage 29 30 The `docker network` command is used to manage Networks. 31 32 To create a network, `docker network create foo`. You can also specify a driver 33 if you have loaded a networking plugin e.g `docker network create -d <plugin_name> foo` 34 35 $ docker network create foo 36 aae601f43744bc1f57c515a16c8c7c4989a2cad577978a32e6910b799a6bccf6 37 $ docker network create -d overlay bar 38 d9989793e2f5fe400a58ef77f706d03f668219688ee989ea68ea78b990fa2406 39 40 `docker network ls` is used to display the currently configured networks 41 42 $ docker network ls 43 NETWORK ID NAME TYPE 44 d367e613ff7f none null 45 bd61375b6993 host host 46 cc455abccfeb bridge bridge 47 aae601f43744 foo bridge 48 d9989793e2f5 bar overlay 49 50 To get detailed information on a network, you can use the `docker network info` 51 command. 52 53 $ docker network info foo 54 Network Id: aae601f43744bc1f57c515a16c8c7c4989a2cad577978a32e6910b799a6bccf6 55 Name: foo 56 Type: null 57 58 If you no longer have need of a network, you can delete it with `docker network rm` 59 60 $ docker network rm bar 61 bar 62 $ docker network ls 63 NETWORK ID NAME TYPE 64 aae601f43744 foo bridge 65 d367e613ff7f none null 66 bd61375b6993 host host 67 cc455abccfeb bridge bridge 68 69 ## User-Defined default network 70 71 Docker daemon supports a configuration flag `--default-network` which takes configuration value of format `DRIVER:NETWORK`, where, 72 `DRIVER` represents the in-built drivers such as bridge, overlay, container, host and none. or Remote drivers via Network Plugins. 73 `NETWORK` is the name of the network created using the `docker network create` command 74 When a container is created and if the network mode (`--net`) is not specified, then this default network will be used to connect 75 the container. If `--default-network` is not specified, the default network will be the `bridge` driver. 76 Example : `docker -d --default-network=overlay:multihost` 77 78 ## Using Services 79 80 Usage: docker service COMMAND [OPTIONS] [arg...] 81 82 Commands: 83 publish Publish a service 84 unpublish Remove a service 85 attach Attach a backend (container) to the service 86 detach Detach the backend from the service 87 ls Lists all services 88 info Display information about a service 89 90 Run 'docker service COMMAND --help' for more information on a command. 91 92 --help=false Print usage 93 94 Assuming we want to publish a service from container `a0ebc12d3e48` on network `foo` as `my-service` we would use the following command: 95 96 $ docker service publish my-service.foo 97 ec56fd74717d00f968c26675c9a77707e49ae64b8e54832ebf78888eb116e428 98 $ docker service attach a0ebc12d3e48 my-service.foo 99 100 This would make the container `a0ebc12d3e48` accessible as `my-service` on network `foo`. Any other container in network `foo` can use DNS to resolve the address of `my-service` 101 102 This can also be acheived by using the `--publish-service` flag for `docker run`: 103 104 docker run -itd --publish-service db.foo postgres 105 106 `db.foo` in this instance means "place the container on network `foo`, and allow other hosts on `foo` to discover it under the name `db`" 107 108 We can see the current services using the `docker service ls` command 109 110 $ docker service ls 111 SERVICE ID NAME NETWORK PROVIDER 112 ec56fd74717d my-service foo a0ebc12d3e48 113 114 To remove the a service: 115 116 $ docker service detach a0ebc12d3e48 my-service.foo 117 $ docker service unpublish my-service.foo 118 119 120 ## Native Multi-host networking 121 122 There is a lot to talk about the native multi-host networking and the `overlay` driver that makes it happen. The technical details are documented under https://github.com/docker/libnetwork/blob/master/docs/overlay.md. 123 Using the above experimental UI `docker network`, `docker service` and `--publish-service`, the user can exercise the power of multi-host networking. 124 125 Since `network` and `service` objects are globally significant, this feature requires distributed states provided by the `libkv` project. 126 Using `libkv`, the user can plug any of the supported Key-Value store (such as consul, etcd or zookeeper). 127 User can specify the Key-Value store of choice using the `--kv-store` daemon flag, which takes configuration value of format `PROVIDER:URL`, where 128 `PROVIDER` is the name of the Key-Value store (such as consul, etcd or zookeeper) and 129 `URL` is the url to reach the Key-Value store. 130 Example : `docker -d --kv-store=consul:localhost:8500` 131 132 133 Send us feedback and comments on [#14083](https://github.com/docker/docker/issues/14083) 134 or on the usual Google Groups (docker-user, docker-dev) and IRC channels. 135