Repository navigation
Description
Proposal: Network Driver
THIS PROPOSAL IS A WORK IN PROGRESS
This proposal brings new functionality and new interfaces to Docker's
networking implementation. Some things are still in flux, but our goal is to
get this approved as there is a sizeable effort internally to make this happen.
We need reviewers and comments on this proposal from the community.
You can see some of the work here
but this is a work in progress, and its implementation (and the maturity of it)
should not reflect the state of this document.
Concepts
Many concepts will be used throughout this and several proposals that are in
process. You may see these repeated with slightly different verbiage or may
contain at-length descriptions of how these interfaces will be implemented.
Here's a basic diagram about how the networking itself operates:
The following includes a description of the interface and its name. The
sub-bullets provide practical examples of these components with the existing
implementation of Docker as an example.
- Driver: executable code which is triggered when certain operations are
requested. - Extension: A collection of Drivers that supply different portions of
functionality to Docker. - State: A key/value store of parameterized data for consumption and mutation by a Driver.
- Sandbox: An isolated environment
- libcontainer's functionality -- for now, this is more or less a standard docker container.
- Endpoint: An addressable endpoint used for communication over a specific network. Endpoints join exactly one network and are expected to create a method of network communication for a container. Endpoints are garbage collected when they no longer belong to any Sandboxes.
- veth pair
- Network: A collection of endpoints that are able to communicate to each other. These networks are intended to be isolated from each other and do not cross communicate. Networks house endpoints which can communicate with each other.
- Our ethernet bridge, iptables rules we use.
Container Network Model (or CNM)
The container network model is a few axioms about how docker wishes to supply
interoperation between networks and containers.
- All containers on a specific network can communicate with each other freely.
- Multiple networks are the way to segment traffic between containers and
should be supported by all drivers. - Multiple endpoints per container are the way to join a container to
multiple networks. - An endpoint is added to a sandbox to provide it with network connectivity.
This has a few consequences:
- Network-based service discovery will replace on-disk and ENV discovery. This
allows discovery to be scoped and more flexible for external implementations.
Implementation of this is still TBD. - Links will be deprecated or only exist on the default network.
Notion of a Default Network
Since Docker is a tool heavily used by both operations and development
personnel to different goals respective to their skill sets, it is critical to
have a functioning "out of the box" implementation for people to use with ease.
Docker will create a "default" network (named default) for the use of basic
networking.
Networks and Endpoints
Endpoints are a part of a Network. The network is (at least in the simplebridge implementation) isolated, but drivers may implement the notion of a network however they choose.
Docker's new system will allow for N networks, but a 'default' network will be
created as a convenience for users, and with the default driver it will
function similarly to the existing network solution now.
Multiple endpoints can be created for a single container, and bound to them at
the same time. The endpoints may live on different networks and may all belong
to one container.
Again, Endpoints as a part of different networks should not be able to communicate with each other in the default implementation. It's expected that network operators would program any bridging between two networks.
Workflow for a Network Driver
At boot, a network driver will be given a replay of its state; this will allow
the driver to return to being in sync with the state of the system, to create
new networks, etc. How replays are handled by drivers is intentionally
undefined.
A network can be requested to be created. In the workflow below, the network
assumes to be created already.
A network driver will be asked at docker run (in order, for a given network):
- To create an endpoint within the network
- To join an endpoint to a sandbox
The driver will also provide port mapping/expose functionality (see below for
API) and communicate with service discovery (TBD).
Network API
Driver abstract interface:
type Driver interface {
// Restore from state
Restore(netstate state.State) error
// Create a new network with the network id and supplied parameters
AddNetwork(netid string, params []string) error
// Remove a network using the network ID.
RemoveNetwork(netid string) error
// Retrieve a network by ID.
GetNetwork(id string) (Network, error)
// List returns the IDs of available networks
ListNetworks() []string
}Network abstract interface:
(note that Link and Unlink here are merely for convenience and do not require
an alternative implementation)
// A network is a perimeter of IP connectivity between network services.
type Network interface {
// Id returns the network's globally unique identifier
Id() string
// List of endpoints that belong to this network.
Endpoints() []Endpoint
// Link makes the specified sandbox reachable as a named endpoint on the network.
// If the endpoint already exists, the call will either fail (replace=false), or
// unlink the previous endpoint.
//
// For example mynet.Link(mysandbox, "db", true) will make mysandbox available as
// "db" on mynet, and will replace the other previous endpoint, if any.
//
// The same sandbox can be linked to multiple networks.
// The same sandbox can be linked to the same network as multiple endpoints.
Link(s sandbox.Sandbox, name string, replace bool) (Endpoint, error)
// Unlink removes the specified endpoint, unlinking the corresponding sandbox from the
// network.
Unlink(name string) error
}Endpoint abstract interface:
// An endpoint represents a particular member of a network, registered under a certain name
// and reachable over IP by other endpoints on the same network.
type Endpoint interface {
// The name of the endpoint.
Name() string
// Expose a port over the network. Publish it as the port to the host if
// requested.
Expose(portspec string, publish bool) error
// The network this endpoint belongs to.
Network() Network
}docker net tool
docker net is the vehicle we're pushing to manipulate networks. The
basic commands are described below:
create: create a networkdestroy: destroy a networkjoin: join a container to a networkleave: remove a container from a network
There will be a forthcoming UI extension to docker run which also selects a
network at run time. This interface is currently to be determined.
Our initial implementation
Our implementation is very similar to docker's existing implementation, which
we are dubbing simplebridge. This driver creates a bridge for each network,
and a veth pair for each endpoint. Networks may contain a set of vxlan peers
which will be attached to the bridge to ensure network connectivity to get
multi-host links.

Activity
lukemarsden commentedon Jan 8, 2015
This looks great, thanks for working on this!
Maybe this is the wrong proposal to comment on (if so, please tell me where to go), but I'm curious specifically about the driver/extension mechanism. Is there any working code that shows
simplebridgeas an extension? And are these extensions planned to be late-bound, out-of-process and delivered as a container?I'm reminded of this tweet from @shykes: https://twitter.com/solomonstre/status/542027779198701568 😄
erikh commentedon Jan 9, 2015
There is! We are retooling to create a separate binary since we have reached our initial PoC. The PoC is here: https://github.com/shykes/docker/tree/extensions/extensions/simplebridge -- please keep in mind this is seriously alpha code and some corners were cut to accomodate our PoC.
To answer the extensions question; yes, it is being worked on as a separate project. For now, we're clarifying the interfaces terminology-wise only specifically for this reason -- the other proposals are not ready yet. I hope this helps, even if it is probably not the answer you were looking for. :)
lukemarsden commentedon Jan 9, 2015
@erikh Awesome! Thanks for sharing this. This looks like really good progress towards the extensions architecture we talked about at DockerCon Europe. I look forward to seeing the extensions proposals when they're ready. I'll leave the rest of this thread for the networking folks to feed back on.
dave-tucker commentedon Jan 9, 2015
@erikh based on @phemmer's comment in #8951 it might be worth highlighting somewhere in the text that this proposal is designed to enable multi-host networking solutions.
erikh commentedon Jan 9, 2015
Will do, probably later today. Will update with a post then.
On Fri, 2015-01-09 at 06:00 -0800, Dave Tucker wrote:
phemmer commentedon Jan 9, 2015
I understood that this model would allow multi-host networking. But what wasn't clear was whether docker would still be implementing multi-host networking, or if it was simply designing this driver scheme so that someone else could implement it.
mrunalp commentedon Jan 9, 2015
@erikh Any links to the "simplebridge" implementation (to get an idea about how it all fits together) ?
thockin commentedon Jan 9, 2015
My comments as I read it through:
"network's globally unique identifier" - how global? a machine? a cluster? UUID?
Is Driver.Link(foo, ...) just an alias to Driver.GetNetwork(foo).Link(...)? why are the args in a different order between them?
Is Endpoint Name() the same as the netif name (e.g. ifconfig) ?
The existence of Expose() as an API suggests that ports are not exposed by default. Is that a requirement or a suggestion?
What does it mean to create/destroy networks in a dumb L2 model where each container gets an SRIOV interface (or the moral equivalent - macvlan, ipvlan, etc)?
Is it expected that 'docker net create' reaches out into the network fabric (off-host) and configures things? How do other nodes learn about the existence of new networks? Or is the concept of a Network purely single-node-centric?
Where do I specify things like "use this specific IP address" or "use this MAC address" or "set MTU to X" or "use IPv6"?
What is a sandbox? Is it a net namespace? How do I allow multiple containers to join the same net namespace (as we do with --net=container:id)?
How are drivers going to be implemented? The simplest answer for just trying things out would be something like an "exec driver" which looks in a directory, e.g. /var/lib/docker/net-drivers/exec. If it finds any executable file, it creates a network driver with the same name. Whenever a driver API has to be called, simply exec that file with some args indicating the API call and params. That way, we can
quickly prototype and iterate on ideas.
MalteJ commentedon Jan 9, 2015
@thockin has written:
I would like to realize that via a docker run network-config string that is passed to the driver. e.g.
docker run -d --network-config="role=frontend,ipv6=true" nginx.The Driver API specification should not define the format of this string. It should be up to the driver to specify the format. This way you can realize various configuration strategies. e.g. you could pass a UUID of some central configuration, a JSON string, an http URL, whatever you can imagine.
I would drop all other network related flags.
Yet I have not understood what
docker netis doing. Could you clarify that?Looks like we still have networking in the main Docker binary?
I would prefer
docker-networkas the default Docker driver binary and for configuration. A separate binary. Not included and no UI in the docker binary.Update
Another option would be, the driver exposes some parameters, that will be added to docker run with a
--network-prefix. E.g. the driver tells Docker it accepts the parametersthen
docker runaccepts the flags--network-roleand--network-ipv6and passes their values to the Driver.timothysc commentedon Jan 9, 2015
Maybe I'm missing something, but re:
'Docker's new system will allow for N networks, but a 'default' network will be
created as a convenience for users...'
I don't see how consensus is maintained across a cluster.
MalteJ commentedon Jan 9, 2015
@timothysc
I don't think the default network will be for clusters. You will have to configure it.
shettyg commentedon Jan 9, 2015
My takeway from this proposal is that it is intended for a single user that owns multiple hosts/VMs. The VMs should have IP reachability with each other. The user deploys docker containers across multiple hosts to get the benefits of redundancy. The containers that run on these hosts should completely trust each other. Docker network daemon peer with each other to create overlay tunnels.
For a multi-tenant environment (i.e people that don't trust each other, but use the same infrastructure/cloud to deploy docker), then a very simplistic workflow like this would be needed.
docker net network create NETWORK-X --username=developer1 --password=****Reaches out to a infrastructure server which verifies credentials and creates a concept of network that belongs to only that user.
docker net endpoint create NETWORK-X ENDPOINT-A --username=.. --password=..Reaches out to an infrastructure server which verifies credentials and creates an endpoint record called ENDPOINT-A that belongs to NETWORK-X. The infrastructure server may decide on an IP address using IPAM and a MAC address for ENDPOINT-A
docker net endpoint add-acl ENDPOINT-A ACL_PROFILE --username=.. --password=..Associates a ACL profile (which can specify things like 'allow only http traffic to this endpoint) with ENDPOINT-A.
docker run --username=.. --password=.. --interface=ENDPOINT-A,ENDPOINT-B -d ubuntu COMMANDThe plugin receives ENDPOINT-A, ENDPOINT-B strings, contacts the infrastructure server, which in-turn creates overlay/underlay networking and provides back the IP address and MAC address to use for the end-points and decides which host to place the container.
If the proposal in question allows extension of 'docker net' tool for different drivers/plugins,
then multi-tenant networking can be achieved.
jainvipin commentedon Jan 9, 2015
overall – a very good proposal!
Quick thoughts and comments:
Concepts:
CNM:
Workflow for a network driver:
Network abstract interface:
docker net tool:
thewmf commentedon Jan 9, 2015
I am strongly in favor of these axioms and the rest looks pretty good but it will take some time to fully understand. The fact that each container will have multiple IP addresses will ripple through service discovery since you need to use a different IP depending on where you're coming from.
@shettyg There's already authentication between docker and dockerd so we should not need networking-specific auth. Multi-tenant details should mostly be left to each driver, but I think there are some common-sense solutions here; e.g. the network ID namespace is implicitly scoped per tenant and is not globally visible, but inter-tenant communication can be allowed if both sides opt in.
erikh commentedon Jan 9, 2015
@mrunalp https://github.com/shykes/docker/tree/extensions/extensions/simplebridge is most of it. the rest of the branch is set up to support it.
45 remaining items
erikh commentedon Jan 19, 2015
I've added a diagram which goes into how Extensions, Drivers, Networks and Endpoints relate to each other. Please inform me all if this is insufficient.
erikh commentedon Jan 19, 2015
Hello again folks,
For starters, please review the proposal again for those of you heavily invested. I have made several updates based on your comments which I hope will clarify things. There's quite a few edits so I will not make note of them here. If you were not mentioned, please, please check the proposal to see if I answered your questions.
@shettyg to answer your questions, we have no intention of mandating ACL, QoS, or other multi-tenancy solutions for drivers at this time. These things will be expected to be implemented by custom drivers with custom configuration.
@MalteJ I really like this flags/configuration system and am working on a way to incorporate it.
Someone asked if Ports were exposed by default. Our feeling is that
exposebecomes less of a network solution and more of a service discovery mechanism, e.g., for finding your redis port or host, etc. We intend to implement a REST API at a link-local IPv6/IPv4 address which should satisfy the service discovery portion. We're also looking at using A and SRV records. There's a large possibility we will implement both (see https://github.com/docker/dnsserver for a prototype of how DNS might work). This will supplant the links feature in a useful way, hopefully.As for compose, machine, swarm integration I would like to point most of you at @bfirsh or @shykes for now, but realize we have no plans to directly integrate with them immediately, but we are evaluating the notion of sharing a state/discovery implementation with the swarm project. I will have more answers on discovery and shared state in a week or two.
I hope this helps! Please let me know if you have additional questions.
thockin commentedon Jan 20, 2015
Collected thoughts as I read again:
"Multiple networks ... segment traffic ... should be supported by all
drivers" - I am still wrestling with a mental model of a dumb network where
I just want to expose network interfaces with real IP addresses (e.g.
ipvlan) - you said "should be supported" so I am assuming it is technically
OK if segmenting is NOT supported?
I don't see how this proposal simplifies the endpoint-per-pod model that
we (kubernetes) use. You specifically say that
docker runtime willcreate an endpoint and join that to a sandbox. I suppose that leaves us
doing what we do today, which is to create a dummy container with the net
namespace (and endpoint) and use --net=container:id for all of the
containers in the pod -- I was hoping this proposal would make that less
fugly. As it is, we just have to explain it with "because that's how
Docker allows us to model the concept". Can we / should we do better with
this proposal?
Network.Endpoints() - does that return a list of endpoints ON THIS HOST,
or a global list?
endpoint.Name() - does this need to be globally unique or just unique on
a given host? For example, if this is the interface name, what happens if
two hosts in the same Network use the same interface name?
On Mon, Jan 19, 2015 at 11:15 AM, Erik Hollensbe [email protected]
wrote:
bboreham commentedon Jan 20, 2015
Is it your intention to mandate both of these in the spec?
If a user desires to join a container to several networks, implemented by drivers from different providers, how will these operations be ordered?
Unlink()be called for all endpoints?erikh commentedon Jan 20, 2015
This is already the way it works now, so I presumed it and overlooked it in the proposal.
Sorry about that! I will correct it now.
bboreham commentedon Jan 27, 2015
Currently, Docker writes the IP address it has allocated for a container into the container's /etc/hosts file. How will this be achieved in the new model?
Related: when a container is attached to several networks, which address will go first in /etc/hosts? Some programs take this as 'my' IP address.
Disclosure: I work on Weave.
bpradipt commentedon Feb 17, 2015
@erikh, I would like to get clarity on few questions primarily from usage point of view
Will it be something like
or
or both ?
fmzhen commentedon Mar 24, 2015
I am very interested in the networking plugin.How's it going now?
zenvdeluca commentedon Apr 30, 2015
@fmzhen http://blog.docker.com/2015/04/docker-networking-takes-a-step-in-the-right-direction-2/
jessfraz commentedon Jul 10, 2015
closed by libnetwork
junneyang commentedon Dec 30, 2016
@shettyg
very good suggestion
but i think it's hard to accomplish this goal
multi-tenant need much more works
and kubernetes also doesn't support this , kubernetes simplify the network model as well
a question:
if we comply with the norm of kubernetes, how do we achieve the goal of multi-tenant?
thanks very much!
thockin commentedon Jan 3, 2017