1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

net: do not create -b/--bridge specified bridge

If the bridge specified using -b/--bridge doesn't
exist, fail instead of attempting to create it.

This is consistent with the docker documentation
on -b/--bridge: "Attach containers to a pre
existing network bridge". 

It is also less surprising in an environment where
the operator expected the bridge to be properly
set up before docker starts and expects docker to
fail fast if the bridge was not up instead of
masking this error and coming up in some
potentially broken state.

With this patch, docker still creates docker0 if
needed and no bridge was explicitly specified.

Docker-DCO-1.1-Signed-off-by: Daniel Norberg <daniel.norberg@gmail.com> (github: danielnorberg)
This commit is contained in:
Daniel Norberg 2014-04-08 14:07:02 -04:00
parent 7dd9c208fd
commit 336199a877

View file

@ -68,12 +68,20 @@ func InitDriver(job *engine.Job) engine.Status {
}
bridgeIface = job.Getenv("BridgeIface")
usingDefaultBridge := false
if bridgeIface == "" {
usingDefaultBridge = true
bridgeIface = DefaultNetworkBridge
}
addr, err := networkdriver.GetIfaceAddr(bridgeIface)
if err != nil {
// If we're not using the default bridge, fail without trying to create it
if !usingDefaultBridge {
job.Logf("bridge not found: %s", bridgeIface)
job.Error(err)
return engine.StatusErr
}
// If the iface is not found, try to create it
job.Logf("creating new bridge for %s", bridgeIface)
if err := createBridge(bridgeIP); err != nil {