mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
plugins: support for host networking
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
9f239281b1
commit
99124c055a
1 changed files with 28 additions and 0 deletions
|
@ -310,6 +310,34 @@ func (p *Plugin) InitSpec(s specs.Spec, libRoot string) (*specs.Spec, error) {
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Options: []string{"rbind", "rshared"},
|
Options: []string{"rbind", "rshared"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if p.PluginObj.Config.Network.Type != "" {
|
||||||
|
// TODO: if net == bridge, use libnetwork controller to create a new plugin-specific bridge, bind mount /etc/hosts and /etc/resolv.conf look at the docker code (allocateNetwork, initialize)
|
||||||
|
if p.PluginObj.Config.Network.Type == "host" {
|
||||||
|
for i, n := range s.Linux.Namespaces {
|
||||||
|
if n.Type == "network" {
|
||||||
|
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
etcHosts := "/etc/hosts"
|
||||||
|
resolvConf := "/etc/resolv.conf"
|
||||||
|
mounts = append(mounts,
|
||||||
|
types.PluginMount{
|
||||||
|
Source: &etcHosts,
|
||||||
|
Destination: etcHosts,
|
||||||
|
Type: "bind",
|
||||||
|
Options: []string{"rbind", "ro"},
|
||||||
|
},
|
||||||
|
types.PluginMount{
|
||||||
|
Source: &resolvConf,
|
||||||
|
Destination: resolvConf,
|
||||||
|
Type: "bind",
|
||||||
|
Options: []string{"rbind", "ro"},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
for _, mount := range mounts {
|
for _, mount := range mounts {
|
||||||
m := specs.Mount{
|
m := specs.Mount{
|
||||||
Destination: mount.Destination,
|
Destination: mount.Destination,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue