Networking API and UX documentation
More doc updates will follow Signed-off-by: Madhu Venugopal <madhu@docker.com> Upstream-commit: dd28ded711417c72d2e228d1ace129ac5fd05f19 Component: engine
This commit is contained in:
@ -71,11 +71,6 @@ to build a Docker binary with the experimental features enabled:
|
||||
|
||||
## Current experimental features
|
||||
|
||||
* [Network plugins](plugins_network.md)
|
||||
* [Networking and Services UI](networking.md)
|
||||
* [Native multi-host networking](network_overlay.md)
|
||||
* [Compose, Swarm and networking integration](compose_swarm_networking.md)
|
||||
|
||||
## How to comment on an experimental feature
|
||||
|
||||
Each feature's documentation includes a list of proposal pull requests or PRs associated with the feature. If you want to comment on or suggest a change to a feature, please add it to the existing feature PR.
|
||||
|
||||
@ -1,238 +0,0 @@
|
||||
# Experimental: Compose, Swarm and Multi-Host Networking
|
||||
|
||||
The [experimental build of Docker](https://github.com/docker/docker/tree/master/experimental) has an entirely new networking system, which enables secure communication between containers on multiple hosts. In combination with Docker Swarm and Docker Compose, you can now run multi-container apps on multi-host clusters with the same tooling and configuration format you use to develop them locally.
|
||||
|
||||
> Note: This functionality is in the experimental stage, and contains some hacks and workarounds which will be removed as it matures.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you start, you’ll need to install the experimental build of Docker, and the latest versions of Machine and Compose.
|
||||
|
||||
- To install the experimental Docker build on a Linux machine, follow the instructions [here](https://github.com/docker/docker/tree/master/experimental#install-docker-experimental).
|
||||
|
||||
- To install the experimental Docker build on a Mac, run these commands:
|
||||
|
||||
$ curl -L https://experimental.docker.com/builds/Darwin/x86_64/docker-latest > /usr/local/bin/docker
|
||||
$ chmod +x /usr/local/bin/docker
|
||||
|
||||
- To install Machine, follow the instructions [here](http://docs.docker.com/machine/).
|
||||
|
||||
- To install Compose, follow the instructions [here](http://docs.docker.com/compose/install/).
|
||||
|
||||
You’ll also need a [Docker Hub](https://hub.docker.com/account/signup/) account and a [Digital Ocean](https://www.digitalocean.com/) account.
|
||||
It works with the amazonec2 driver as well (by adapting the commands accordingly), except you'll need to manually open the ports 8500 (consul) and 7946 (serf) by editing the inbound rules of the corresponding security group.
|
||||
|
||||
## Set up a swarm with multi-host networking
|
||||
|
||||
Set the `DIGITALOCEAN_ACCESS_TOKEN` environment variable to a valid Digital Ocean API token, which you can generate in the [API panel](https://cloud.digitalocean.com/settings/applications).
|
||||
|
||||
export DIGITALOCEAN_ACCESS_TOKEN=abc12345
|
||||
|
||||
Start a consul server:
|
||||
|
||||
docker-machine --debug create \
|
||||
-d digitalocean \
|
||||
--engine-install-url="https://experimental.docker.com" \
|
||||
consul
|
||||
|
||||
docker $(docker-machine config consul) run -d \
|
||||
-p "8500:8500" \
|
||||
-h "consul" \
|
||||
progrium/consul -server -bootstrap
|
||||
|
||||
(In a real world setting you’d set up a distributed consul, but that’s beyond the scope of this guide!)
|
||||
|
||||
Create a Swarm token:
|
||||
|
||||
export SWARM_TOKEN=$(docker run swarm create)
|
||||
|
||||
Next, you create a Swarm master with Machine:
|
||||
|
||||
docker-machine --debug create \
|
||||
-d digitalocean \
|
||||
--digitalocean-image="ubuntu-14-04-x64" \
|
||||
--engine-install-url="https://experimental.docker.com" \
|
||||
--engine-opt="default-network=overlay:multihost" \
|
||||
--engine-opt="kv-store=consul:$(docker-machine ip consul):8500" \
|
||||
--engine-label="com.docker.network.driver.overlay.bind_interface=eth0" \
|
||||
swarm-0
|
||||
|
||||
Usually Machine can create Swarms for you, but it doesn't yet fully support multi-host networks yet, so you'll have to start up the Swarm manually:
|
||||
|
||||
docker $(docker-machine config swarm-0) run -d \
|
||||
--restart="always" \
|
||||
--net="bridge" \
|
||||
swarm:latest join \
|
||||
--addr "$(docker-machine ip swarm-0):2376" \
|
||||
"token://$SWARM_TOKEN"
|
||||
|
||||
docker $(docker-machine config swarm-0) run -d \
|
||||
--restart="always" \
|
||||
--net="bridge" \
|
||||
-p "3376:3376" \
|
||||
-v "/etc/docker:/etc/docker" \
|
||||
swarm:latest manage \
|
||||
--tlsverify \
|
||||
--tlscacert="/etc/docker/ca.pem" \
|
||||
--tlscert="/etc/docker/server.pem" \
|
||||
--tlskey="/etc/docker/server-key.pem" \
|
||||
-H "tcp://0.0.0.0:3376" \
|
||||
--strategy spread \
|
||||
"token://$SWARM_TOKEN"
|
||||
|
||||
Create a Swarm node:
|
||||
|
||||
docker-machine --debug create \
|
||||
-d digitalocean \
|
||||
--digitalocean-image="ubuntu-14-10-x64" \
|
||||
--engine-install-url="https://experimental.docker.com" \
|
||||
--engine-opt="default-network=overlay:multihost" \
|
||||
--engine-opt="kv-store=consul:$(docker-machine ip consul):8500" \
|
||||
--engine-label="com.docker.network.driver.overlay.bind_interface=eth0" \
|
||||
--engine-label="com.docker.network.driver.overlay.neighbor_ip=$(docker-machine ip swarm-0)" \
|
||||
swarm-1
|
||||
|
||||
docker $(docker-machine config swarm-1) run -d \
|
||||
--restart="always" \
|
||||
--net="bridge" \
|
||||
swarm:latest join \
|
||||
--addr "$(docker-machine ip swarm-1):2376" \
|
||||
"token://$SWARM_TOKEN"
|
||||
|
||||
You can create more Swarm nodes if you want - it’s best to give them sensible names (swarm-2, swarm-3, etc).
|
||||
|
||||
Finally, point Docker at your swarm:
|
||||
|
||||
export DOCKER_HOST=tcp://"$(docker-machine ip swarm-0):3376"
|
||||
export DOCKER_TLS_VERIFY=1
|
||||
export DOCKER_CERT_PATH="$HOME/.docker/machine/machines/swarm-0"
|
||||
|
||||
## Run containers and get them communicating
|
||||
|
||||
Now that you’ve got a swarm up and running, you can create containers on it just like a single Docker instance:
|
||||
|
||||
$ docker run busybox echo hello world
|
||||
hello world
|
||||
|
||||
If you run `docker ps -a`, you can see what node that container was started on by looking at its name (here it’s swarm-3):
|
||||
|
||||
$ docker ps -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
41f59749737b busybox "echo hello world" 15 seconds ago Exited (0) 13 seconds ago swarm-3/trusting_leakey
|
||||
|
||||
As you start more containers, they’ll be placed on different nodes across the cluster, thanks to Swarm’s default “spread” scheduling strategy.
|
||||
|
||||
Every container started on this swarm will use the “overlay:multihost” network by default, meaning they can all intercommunicate. Each container gets an IP address on that network, and an `/etc/hosts` file which will be updated on-the-fly with every other container’s IP address and name. That means that if you have a running container named ‘foo’, other containers can access it at the hostname ‘foo’.
|
||||
|
||||
Let’s verify that multi-host networking is functioning. Start a long-running container:
|
||||
|
||||
$ docker run -d --name long-running busybox top
|
||||
<container id>
|
||||
|
||||
If you start a new container and inspect its /etc/hosts file, you’ll see the long-running container in there:
|
||||
|
||||
$ docker run busybox cat /etc/hosts
|
||||
...
|
||||
172.21.0.6 long-running
|
||||
|
||||
Verify that connectivity works between containers:
|
||||
|
||||
$ docker run busybox ping long-running
|
||||
PING long-running (172.21.0.6): 56 data bytes
|
||||
64 bytes from 172.21.0.6: seq=0 ttl=64 time=7.975 ms
|
||||
64 bytes from 172.21.0.6: seq=1 ttl=64 time=1.378 ms
|
||||
64 bytes from 172.21.0.6: seq=2 ttl=64 time=1.348 ms
|
||||
^C
|
||||
--- long-running ping statistics ---
|
||||
3 packets transmitted, 3 packets received, 0% packet loss
|
||||
round-trip min/avg/max = 1.140/2.099/7.975 ms
|
||||
|
||||
## Run a Compose application
|
||||
|
||||
Here’s an example of a simple Python + Redis app using multi-host networking on a swarm.
|
||||
|
||||
Create a directory for the app:
|
||||
|
||||
$ mkdir composetest
|
||||
$ cd composetest
|
||||
|
||||
Inside this directory, create 2 files.
|
||||
|
||||
First, create `app.py` - a simple web app that uses the Flask framework and increments a value in Redis:
|
||||
|
||||
from flask import Flask
|
||||
from redis import Redis
|
||||
import os
|
||||
app = Flask(__name__)
|
||||
redis = Redis(host='composetest_redis_1', port=6379)
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
redis.incr('hits')
|
||||
return 'Hello World! I have been seen %s times.' % redis.get('hits')
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", debug=True)
|
||||
|
||||
Note that we’re connecting to a host called `composetest_redis_1` - this is the name of the Redis container that Compose will start.
|
||||
|
||||
Second, create a Dockerfile for the app container:
|
||||
|
||||
FROM python:2.7
|
||||
RUN pip install flask redis
|
||||
ADD . /code
|
||||
WORKDIR /code
|
||||
CMD ["python", "app.py"]
|
||||
|
||||
Build the Docker image and push it to the Hub (you’ll need a Hub account). Replace `<username>` with your Docker Hub username:
|
||||
|
||||
$ docker build -t <username>/counter .
|
||||
$ docker push <username>/counter
|
||||
|
||||
Next, create a `docker-compose.yml`, which defines the configuration for the web and redis containers. Once again, replace `<username>` with your Hub username:
|
||||
|
||||
web:
|
||||
image: <username>/counter
|
||||
ports:
|
||||
- "80:5000"
|
||||
redis:
|
||||
image: redis
|
||||
|
||||
Now start the app:
|
||||
|
||||
$ docker-compose up -d
|
||||
Pulling web (username/counter:latest)...
|
||||
swarm-0: Pulling username/counter:latest... : downloaded
|
||||
swarm-2: Pulling username/counter:latest... : downloaded
|
||||
swarm-1: Pulling username/counter:latest... : downloaded
|
||||
swarm-3: Pulling username/counter:latest... : downloaded
|
||||
swarm-4: Pulling username/counter:latest... : downloaded
|
||||
Creating composetest_web_1...
|
||||
Pulling redis (redis:latest)...
|
||||
swarm-2: Pulling redis:latest... : downloaded
|
||||
swarm-1: Pulling redis:latest... : downloaded
|
||||
swarm-3: Pulling redis:latest... : downloaded
|
||||
swarm-4: Pulling redis:latest... : downloaded
|
||||
swarm-0: Pulling redis:latest... : downloaded
|
||||
Creating composetest_redis_1...
|
||||
|
||||
Swarm has created containers for both web and redis, and placed them on different nodes, which you can check with `docker ps`:
|
||||
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
92faad2135c9 redis "/entrypoint.sh redi 43 seconds ago Up 42 seconds swarm-2/composetest_redis_1
|
||||
adb809e5cdac username/counter "/bin/sh -c 'python 55 seconds ago Up 54 seconds 45.67.8.9:80->5000/tcp swarm-1/composetest_web_1
|
||||
|
||||
You can also see that the web container has exposed port 80 on its swarm node. If you curl that IP, you’ll get a response from the container:
|
||||
|
||||
$ curl http://45.67.8.9
|
||||
Hello World! I have been seen 1 times.
|
||||
|
||||
If you hit it repeatedly, the counter will increment, demonstrating that the web and redis container are communicating:
|
||||
|
||||
$ curl http://45.67.8.9
|
||||
Hello World! I have been seen 2 times.
|
||||
$ curl http://45.67.8.9
|
||||
Hello World! I have been seen 3 times.
|
||||
$ curl http://45.67.8.9
|
||||
Hello World! I have been seen 4 times.
|
||||
@ -1,14 +0,0 @@
|
||||
# Native Multi-host networking
|
||||
|
||||
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.
|
||||
Using the above experimental UI `docker network`, `docker service` and `--publish-service`, the user can exercise the power of multi-host networking.
|
||||
|
||||
Since `network` and `service` objects are globally significant, this feature requires distributed states provided by the `libkv` project.
|
||||
Using `libkv`, the user can plug any of the supported Key-Value store (such as consul, etcd or zookeeper).
|
||||
User can specify the Key-Value store of choice using the `--cluster-store` daemon flag, which takes configuration value of format `PROVIDER:URL`, where
|
||||
`PROVIDER` is the name of the Key-Value store (such as consul, etcd or zookeeper) and
|
||||
`URL` is the url to reach the Key-Value store.
|
||||
Example : `docker daemon --cluster-store=consul://localhost:8500`
|
||||
|
||||
Send us feedback and comments on [#14083](https://github.com/docker/docker/issues/14083)
|
||||
or on the usual Google Groups (docker-user, docker-dev) and IRC channels.
|
||||
@ -1,120 +0,0 @@
|
||||
# Experimental: Networking and Services
|
||||
|
||||
In this feature:
|
||||
|
||||
- `network` and `service` become first class objects in the Docker UI
|
||||
- one can now create networks, publish services on that network and attach containers to the services
|
||||
- Native multi-host networking
|
||||
- `network` and `service` objects are globally significant and provides multi-host container connectivity natively
|
||||
- Inbuilt simple Service Discovery
|
||||
- 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
|
||||
- Batteries included but removable
|
||||
- Docker provides inbuilt native multi-host networking by default & can be swapped by any remote driver provided by external plugins.
|
||||
|
||||
This is an experimental feature. For information on installing and using experimental features, see [the experimental feature overview](README.md).
|
||||
|
||||
## Using Networks
|
||||
|
||||
Usage: docker network [OPTIONS] COMMAND [OPTIONS] [arg...]
|
||||
|
||||
Commands:
|
||||
create Create a network
|
||||
rm Remove a network
|
||||
ls List all networks
|
||||
info Display information of a network
|
||||
|
||||
Run 'docker network COMMAND --help' for more information on a command.
|
||||
|
||||
--help=false Print usage
|
||||
|
||||
The `docker network` command is used to manage Networks.
|
||||
|
||||
To create a network, `docker network create foo`. You can also specify a driver
|
||||
if you have loaded a networking plugin e.g `docker network create -d <plugin_name> foo`
|
||||
|
||||
$ docker network create foo
|
||||
aae601f43744bc1f57c515a16c8c7c4989a2cad577978a32e6910b799a6bccf6
|
||||
$ docker network create -d overlay bar
|
||||
d9989793e2f5fe400a58ef77f706d03f668219688ee989ea68ea78b990fa2406
|
||||
|
||||
`docker network ls` is used to display the currently configured networks
|
||||
|
||||
$ docker network ls
|
||||
NETWORK ID NAME TYPE
|
||||
d367e613ff7f none null
|
||||
bd61375b6993 host host
|
||||
cc455abccfeb bridge bridge
|
||||
aae601f43744 foo bridge
|
||||
d9989793e2f5 bar overlay
|
||||
|
||||
To get detailed information on a network, you can use the `docker network info`
|
||||
command.
|
||||
|
||||
$ docker network info foo
|
||||
Network Id: aae601f43744bc1f57c515a16c8c7c4989a2cad577978a32e6910b799a6bccf6
|
||||
Name: foo
|
||||
Type: null
|
||||
|
||||
If you no longer have need of a network, you can delete it with `docker network rm`
|
||||
|
||||
$ docker network rm bar
|
||||
bar
|
||||
$ docker network ls
|
||||
NETWORK ID NAME TYPE
|
||||
aae601f43744 foo bridge
|
||||
d367e613ff7f none null
|
||||
bd61375b6993 host host
|
||||
cc455abccfeb bridge bridge
|
||||
|
||||
## User-Defined default network
|
||||
|
||||
Docker daemon supports a configuration flag `--default-network` which takes configuration value of format `DRIVER:NETWORK`, where,
|
||||
`DRIVER` represents the in-built drivers such as bridge, overlay, container, host and none. or Remote drivers via Network Plugins.
|
||||
`NETWORK` is the name of the network created using the `docker network create` command
|
||||
When a container is created and if the network mode (`--net`) is not specified, then this default network will be used to connect
|
||||
the container. If `--default-network` is not specified, the default network will be the `bridge` driver.
|
||||
Example : `docker daemon --default-network=overlay:multihost`
|
||||
|
||||
## Using Services
|
||||
|
||||
Usage: docker service COMMAND [OPTIONS] [arg...]
|
||||
|
||||
Commands:
|
||||
publish Publish a service
|
||||
unpublish Remove a service
|
||||
attach Attach a backend (container) to the service
|
||||
detach Detach the backend from the service
|
||||
ls Lists all services
|
||||
info Display information about a service
|
||||
|
||||
Run 'docker service COMMAND --help' for more information on a command.
|
||||
|
||||
--help=false Print usage
|
||||
|
||||
Assuming we want to publish a service from container `a0ebc12d3e48` on network `foo` as `my-service` we would use the following command:
|
||||
|
||||
$ docker service publish my-service.foo
|
||||
ec56fd74717d00f968c26675c9a77707e49ae64b8e54832ebf78888eb116e428
|
||||
$ docker service attach a0ebc12d3e48 my-service.foo
|
||||
|
||||
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`
|
||||
|
||||
This can also be achieved by using the `--publish-service` flag for `docker run`:
|
||||
|
||||
docker run -itd --publish-service db.foo postgres
|
||||
|
||||
`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`"
|
||||
|
||||
We can see the current services using the `docker service ls` command
|
||||
|
||||
$ docker service ls
|
||||
SERVICE ID NAME NETWORK PROVIDER
|
||||
ec56fd74717d my-service foo a0ebc12d3e48
|
||||
|
||||
To remove the a service:
|
||||
|
||||
$ docker service detach a0ebc12d3e48 my-service.foo
|
||||
$ docker service unpublish my-service.foo
|
||||
|
||||
Send us feedback and comments on [#14083](https://github.com/docker/docker/issues/14083)
|
||||
or on the usual Google Groups (docker-user, docker-dev) and IRC channels.
|
||||
@ -1,489 +0,0 @@
|
||||
# Networking API
|
||||
|
||||
### List networks
|
||||
|
||||
`GET /networks`
|
||||
|
||||
List networks
|
||||
|
||||
**Example request**:
|
||||
|
||||
GET /networks HTTP/1.1
|
||||
|
||||
**Example response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"name": "none",
|
||||
"id": "8e4e55c6863ef4241c548c1c6fc77289045e9e5d5b5e4875401a675326981898",
|
||||
"type": "null",
|
||||
"endpoints": []
|
||||
},
|
||||
{
|
||||
"name": "host",
|
||||
"id": "062b6d9ea7913fde549e2d186ff0402770658f8c4e769958e1b943ff4e675011",
|
||||
"type": "host",
|
||||
"endpoints": []
|
||||
},
|
||||
{
|
||||
"name": "bridge",
|
||||
"id": "a87dd9a9d58f030962df1c15fb3fa142fbd9261339de458bc89be1895cef2c70",
|
||||
"type": "bridge",
|
||||
"endpoints": []
|
||||
}
|
||||
]
|
||||
|
||||
Query Parameters:
|
||||
|
||||
- **name** – Filter results with the given name
|
||||
- **partial-id** – Filter results using the partial network ID
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Create a Network
|
||||
|
||||
`POST /networks`
|
||||
|
||||
**Example request**
|
||||
|
||||
POST /networks HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "foo",
|
||||
"network_type": "",
|
||||
"options": {}
|
||||
}
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
"32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653",
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad request
|
||||
- **500** – server error
|
||||
|
||||
### Get a network
|
||||
|
||||
`GET /networks/<network_id>`
|
||||
|
||||
Get a network
|
||||
|
||||
**Example request**:
|
||||
|
||||
GET /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653 HTTP/1.1
|
||||
|
||||
**Example response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "foo",
|
||||
"id": "32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653",
|
||||
"type": "bridge",
|
||||
"endpoints": []
|
||||
}
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **404** – not found
|
||||
- **500** – server error
|
||||
|
||||
### List a networks endpoints
|
||||
|
||||
`GET /networks/<network_id>/endpoints`
|
||||
|
||||
**Example request**
|
||||
|
||||
GET /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653/endpoints HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"id": "7e0c116b882ee489a8a5345a2638c0129099aa47f4ba114edde34e75c1e4ae0d",
|
||||
"name": "/lonely_pasteur",
|
||||
"network": "foo"
|
||||
}
|
||||
]
|
||||
|
||||
Query Parameters:
|
||||
|
||||
- **name** – Filter results with the given name
|
||||
- **partial-id** – Filter results using the partial network ID
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Create an endpoint on a network
|
||||
|
||||
`POST /networks/<network_id>/endpoints`
|
||||
|
||||
**Example request**
|
||||
|
||||
POST /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653/endpoints HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "baz",
|
||||
"exposed_ports": [
|
||||
{
|
||||
"proto": 6,
|
||||
"port": 8080
|
||||
}
|
||||
],
|
||||
"port_mapping": null
|
||||
}
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
"b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a"
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Get an endpoint
|
||||
|
||||
`GET /networks/<network_id>/endpoints/<endpoint_id>`
|
||||
|
||||
**Example request**
|
||||
|
||||
GET /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653/endpoints/b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a",
|
||||
"name": "baz",
|
||||
"network": "foo"
|
||||
}
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **404** - not found
|
||||
- **500** – server error
|
||||
|
||||
### Join an endpoint to a container
|
||||
|
||||
`POST /networks/<network_id>/endpoints/<endpoint_id>/containers`
|
||||
|
||||
**Example request**
|
||||
|
||||
POST /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653//endpoints/b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a/containers HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"container_id": "e76f406417031bd24c17aeb9bb2f5968b628b9fb6067da264b234544754bf857",
|
||||
"host_name": null,
|
||||
"domain_name": null,
|
||||
"hosts_path": null,
|
||||
"resolv_conf_path": null,
|
||||
"dns": null,
|
||||
"extra_hosts": null,
|
||||
"parent_updates": null,
|
||||
"use_default_sandbox": true
|
||||
}
|
||||
|
||||
**Example response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
"/var/run/docker/netns/e76f40641703"
|
||||
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **404** - not found
|
||||
- **500** – server error
|
||||
|
||||
### Detach an endpoint from a container
|
||||
|
||||
`DELETE /networks/<network_id>/endpoints/<endpoint_id>/containers/<container_id>`
|
||||
|
||||
**Example request**
|
||||
|
||||
DELETE /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653/endpoints/b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a/containers/e76f406417031bd24c17aeb9bb2f5968b628b9fb6067da264b234544754bf857 HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
**Example response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **404** - not found
|
||||
- **500** – server error
|
||||
|
||||
|
||||
### Delete an endpoint
|
||||
|
||||
`DELETE /networks/<network_id>/endpoints/<endpoint_id>`
|
||||
|
||||
**Example request**
|
||||
|
||||
DELETE /networks/32fbf63200e2897f5de72cb2a4b653e4b1a523b15116e96e3d73f7849e583653/endpoints/b18b795af8bad85cdd691ff24ffa2b08c02219d51992309dd120322689d2ab5a HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **404** - not found
|
||||
- **500** – server error
|
||||
|
||||
### Delete a network
|
||||
|
||||
`DELETE /networks/<network_id>`
|
||||
|
||||
Delete a network
|
||||
|
||||
**Example request**:
|
||||
|
||||
DELETE /networks/0984d158bd8ae108e4d6bc8fcabedf51da9a174b32cc777026d4a29045654951 HTTP/1.1
|
||||
|
||||
**Example response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **404** – not found
|
||||
- **500** – server error
|
||||
|
||||
# Services API
|
||||
|
||||
### Publish a Service
|
||||
|
||||
`POST /services`
|
||||
|
||||
Publish a service
|
||||
|
||||
**Example Request**
|
||||
|
||||
POST /services HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "bar",
|
||||
"network_name": "foo",
|
||||
"exposed_ports": null,
|
||||
"port_mapping": null
|
||||
}
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
"0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff"
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Get a Service
|
||||
|
||||
`GET /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff`
|
||||
|
||||
Get a service
|
||||
|
||||
**Example Request**:
|
||||
|
||||
GET /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff HTTP/1.1
|
||||
|
||||
**Example Response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "bar",
|
||||
"id": "0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff",
|
||||
"network": "foo"
|
||||
}
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **404** - not found
|
||||
- **500** – server error
|
||||
|
||||
### Attach a backend to a service
|
||||
|
||||
`POST /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff/backend`
|
||||
|
||||
Attach a backend to a service
|
||||
|
||||
**Example Request**:
|
||||
|
||||
POST /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff/backend HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"container_id": "98c5241f9475e9efc17e7198e931fb48166010b80f96d48df204e251378ca547",
|
||||
"host_name": "",
|
||||
"domain_name": "",
|
||||
"hosts_path": "",
|
||||
"resolv_conf_path": "",
|
||||
"dns": null,
|
||||
"extra_hosts": null,
|
||||
"parent_updates": null,
|
||||
"use_default_sandbox": false
|
||||
}
|
||||
|
||||
**Example Response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
"/var/run/docker/netns/98c5241f9475"
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Get Backends for a Service
|
||||
|
||||
Get all backends for a given service
|
||||
|
||||
**Example Request**
|
||||
|
||||
GET /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff/backend HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"id": "98c5241f9475e9efc17e7198e931fb48166010b80f96d48df204e251378ca547"
|
||||
}
|
||||
]
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### List Services
|
||||
|
||||
`GET /services`
|
||||
|
||||
List services
|
||||
|
||||
**Example request**:
|
||||
|
||||
GET /services HTTP/1.1
|
||||
|
||||
**Example response**:
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"name": "/stupefied_stallman",
|
||||
"id": "c826b26bf736fb4a77db33f83562e59f9a770724e259ab9c3d50d948f8233ae4",
|
||||
"network": "bridge"
|
||||
},
|
||||
{
|
||||
"name": "bar",
|
||||
"id": "0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff",
|
||||
"network": "foo"
|
||||
}
|
||||
]
|
||||
|
||||
Query Parameters:
|
||||
|
||||
- **name** – Filter results with the given name
|
||||
- **partial-id** – Filter results using the partial network ID
|
||||
- **network** - Filter results by the given network
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Detach a Backend from a Service
|
||||
|
||||
`DELETE /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff/backend/98c5241f9475e9efc17e7198e931fb48166010b80f96d48df204e251378ca547`
|
||||
|
||||
Detach a backend from a service
|
||||
|
||||
**Example Request**
|
||||
|
||||
DELETE /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff/backend/98c5241f9475e9efc17e7198e931fb48166010b80f96d48df204e251378ca547 HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
|
||||
### Un-Publish a Service
|
||||
|
||||
`DELETE /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff`
|
||||
|
||||
Unpublish a service
|
||||
|
||||
**Example Request**
|
||||
|
||||
DELETE /services/0aee0899e6c5e903cf3ef2bdc28a1c9aaf639c8c8c331fa4ae26344d9e32c1ff HTTP/1.1
|
||||
|
||||
**Example Response**
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
|
||||
Status Codes:
|
||||
|
||||
- **200** – no error
|
||||
- **400** – bad parameter
|
||||
- **500** – server error
|
||||
@ -1,45 +0,0 @@
|
||||
# Experimental: Docker network driver plugins
|
||||
|
||||
Docker supports network driver plugins via
|
||||
[LibNetwork](https://github.com/docker/libnetwork). Network driver plugins are
|
||||
implemented as "remote drivers" for LibNetwork, which shares plugin
|
||||
infrastructure with Docker. In effect this means that network driver plugins
|
||||
are activated in the same way as other plugins, and use the same kind of
|
||||
protocol.
|
||||
|
||||
## Using network driver plugins
|
||||
|
||||
The means of installing and running a network driver plugin will depend on the
|
||||
particular plugin.
|
||||
|
||||
Once running however, network driver plugins are used just like the built-in
|
||||
network drivers: by being mentioned as a driver in network-oriented Docker
|
||||
commands. For example,
|
||||
|
||||
docker network create -d weave mynet
|
||||
|
||||
Some network driver plugins are listed in [plugins.md](/docs/extend/plugins.md)
|
||||
|
||||
The network thus created is owned by the plugin, so subsequent commands
|
||||
referring to that network will also be run through the plugin.
|
||||
|
||||
## Network driver plugin protocol
|
||||
|
||||
The network driver protocol, additional to the plugin activation call, is
|
||||
documented as part of LibNetwork:
|
||||
[https://github.com/docker/libnetwork/blob/master/docs/remote.md](https://github.com/docker/libnetwork/blob/master/docs/remote.md).
|
||||
|
||||
# Related GitHub PRs and issues
|
||||
|
||||
Please record your feedback in the following issue, on the usual
|
||||
Google Groups, or the IRC channel #docker-network.
|
||||
|
||||
- [#14083](https://github.com/docker/docker/issues/14083) Feedback on
|
||||
experimental networking features
|
||||
|
||||
Other pertinent issues:
|
||||
|
||||
- [#13977](https://github.com/docker/docker/issues/13977) UI for using networks
|
||||
- [#14023](https://github.com/docker/docker/pull/14023) --default-network option
|
||||
- [#14051](https://github.com/docker/docker/pull/14051) --publish-service option
|
||||
- [#13441](https://github.com/docker/docker/pull/13441) (Deprecated) Networks API & UI
|
||||
Reference in New Issue
Block a user