Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 99124c055ac5d145737fe432ffc2e62e320d3d96)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
| ... | ... |
@@ -311,6 +311,34 @@ func (p *Plugin) InitSpec(s specs.Spec, libRoot string) (*specs.Spec, error) {
|
| 311 | 311 |
Type: "bind", |
| 312 | 312 |
Options: []string{"rbind", "rshared"},
|
| 313 | 313 |
}) |
| 314 |
+ |
|
| 315 |
+ if p.PluginObj.Config.Network.Type != "" {
|
|
| 316 |
+ // 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) |
|
| 317 |
+ if p.PluginObj.Config.Network.Type == "host" {
|
|
| 318 |
+ for i, n := range s.Linux.Namespaces {
|
|
| 319 |
+ if n.Type == "network" {
|
|
| 320 |
+ s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...) |
|
| 321 |
+ break |
|
| 322 |
+ } |
|
| 323 |
+ } |
|
| 324 |
+ } |
|
| 325 |
+ etcHosts := "/etc/hosts" |
|
| 326 |
+ resolvConf := "/etc/resolv.conf" |
|
| 327 |
+ mounts = append(mounts, |
|
| 328 |
+ types.PluginMount{
|
|
| 329 |
+ Source: &etcHosts, |
|
| 330 |
+ Destination: etcHosts, |
|
| 331 |
+ Type: "bind", |
|
| 332 |
+ Options: []string{"rbind", "ro"},
|
|
| 333 |
+ }, |
|
| 334 |
+ types.PluginMount{
|
|
| 335 |
+ Source: &resolvConf, |
|
| 336 |
+ Destination: resolvConf, |
|
| 337 |
+ Type: "bind", |
|
| 338 |
+ Options: []string{"rbind", "ro"},
|
|
| 339 |
+ }) |
|
| 340 |
+ } |
|
| 341 |
+ |
|
| 314 | 342 |
for _, mount := range mounts {
|
| 315 | 343 |
m := specs.Mount{
|
| 316 | 344 |
Destination: mount.Destination, |