Signed-off-by: Santhosh Manohar <santhosh@docker.com>
Santhosh Manohar authored on 2016/01/22 13:49:02... | ... |
@@ -21,7 +21,7 @@ import ( |
21 | 21 |
runconfigopts "github.com/docker/docker/runconfig/opts" |
22 | 22 |
"github.com/docker/docker/utils" |
23 | 23 |
"github.com/docker/docker/volume" |
24 |
- "github.com/docker/engine-api/types/container" |
|
24 |
+ containertypes "github.com/docker/engine-api/types/container" |
|
25 | 25 |
"github.com/docker/engine-api/types/network" |
26 | 26 |
"github.com/docker/go-connections/nat" |
27 | 27 |
"github.com/docker/libnetwork" |
... | ... |
@@ -290,7 +290,7 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network) ([] |
290 | 290 |
} |
291 | 291 |
} |
292 | 292 |
|
293 |
- if !container.HostConfig.NetworkMode.IsUserDefined() { |
|
293 |
+ if !containertypes.NetworkMode(n.Name()).IsUserDefined() { |
|
294 | 294 |
createOptions = append(createOptions, libnetwork.CreateOptionDisableResolution()) |
295 | 295 |
} |
296 | 296 |
|
... | ... |
@@ -577,7 +577,7 @@ func (container *Container) IpcMounts() []execdriver.Mount { |
577 | 577 |
return mounts |
578 | 578 |
} |
579 | 579 |
|
580 |
-func updateCommand(c *execdriver.Command, resources container.Resources) { |
|
580 |
+func updateCommand(c *execdriver.Command, resources containertypes.Resources) { |
|
581 | 581 |
c.Resources.BlkioWeight = resources.BlkioWeight |
582 | 582 |
c.Resources.CPUShares = resources.CPUShares |
583 | 583 |
c.Resources.CPUPeriod = resources.CPUPeriod |
... | ... |
@@ -591,7 +591,7 @@ func updateCommand(c *execdriver.Command, resources container.Resources) { |
591 | 591 |
} |
592 | 592 |
|
593 | 593 |
// UpdateContainer updates resources of a container. |
594 |
-func (container *Container) UpdateContainer(hostConfig *container.HostConfig) error { |
|
594 |
+func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error { |
|
595 | 595 |
container.Lock() |
596 | 596 |
|
597 | 597 |
resources := hostConfig.Resources |
... | ... |
@@ -1301,3 +1301,26 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) { |
1301 | 1301 |
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "bar") |
1302 | 1302 |
c.Assert(err, check.IsNil) |
1303 | 1303 |
} |
1304 |
+ |
|
1305 |
+func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *check.C) { |
|
1306 |
+ testRequires(c, DaemonIsLinux, NotUserNamespace) |
|
1307 |
+ dockerCmd(c, "network", "create", "-d", "bridge", "br.net1") |
|
1308 |
+ |
|
1309 |
+ dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c1.net1", "busybox", "top") |
|
1310 |
+ c.Assert(waitRun("c1.net1"), check.IsNil) |
|
1311 |
+ |
|
1312 |
+ dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c2.net1", "busybox", "top") |
|
1313 |
+ c.Assert(waitRun("c2.net1"), check.IsNil) |
|
1314 |
+ |
|
1315 |
+ // ping first container by its unqualified name |
|
1316 |
+ _, _, err := dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1") |
|
1317 |
+ c.Assert(err, check.IsNil) |
|
1318 |
+ |
|
1319 |
+ // ping first container by its qualified name |
|
1320 |
+ _, _, err = dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1.br.net1") |
|
1321 |
+ c.Assert(err, check.IsNil) |
|
1322 |
+ |
|
1323 |
+ // ping with first qualified name masked by an additional domain. should fail |
|
1324 |
+ _, _, err = dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1.br.net1.google.com") |
|
1325 |
+ c.Assert(err, check.NotNil) |
|
1326 |
+} |
... | ... |
@@ -22,6 +22,7 @@ import ( |
22 | 22 |
"github.com/docker/docker/pkg/mount" |
23 | 23 |
"github.com/docker/docker/runconfig" |
24 | 24 |
"github.com/docker/go-connections/nat" |
25 |
+ "github.com/docker/libnetwork/netutils" |
|
25 | 26 |
"github.com/docker/libnetwork/resolvconf" |
26 | 27 |
"github.com/go-check/check" |
27 | 28 |
) |
... | ... |
@@ -1258,13 +1259,13 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) { |
1258 | 1258 |
c.Fatalf("/etc/resolv.conf does not exist") |
1259 | 1259 |
} |
1260 | 1260 |
|
1261 |
- hostNamservers := resolvconf.GetNameservers(origResolvConf) |
|
1261 |
+ hostNamservers := resolvconf.GetNameservers(origResolvConf, netutils.IP) |
|
1262 | 1262 |
hostSearch := resolvconf.GetSearchDomains(origResolvConf) |
1263 | 1263 |
|
1264 | 1264 |
var out string |
1265 | 1265 |
out, _ = dockerCmd(c, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf") |
1266 | 1266 |
|
1267 |
- if actualNameservers := resolvconf.GetNameservers([]byte(out)); string(actualNameservers[0]) != "127.0.0.1" { |
|
1267 |
+ if actualNameservers := resolvconf.GetNameservers([]byte(out), netutils.IP); string(actualNameservers[0]) != "127.0.0.1" { |
|
1268 | 1268 |
c.Fatalf("expected '127.0.0.1', but says: %q", string(actualNameservers[0])) |
1269 | 1269 |
} |
1270 | 1270 |
|
... | ... |
@@ -1280,7 +1281,7 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) { |
1280 | 1280 |
|
1281 | 1281 |
out, _ = dockerCmd(c, "run", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf") |
1282 | 1282 |
|
1283 |
- actualNameservers := resolvconf.GetNameservers([]byte(out)) |
|
1283 |
+ actualNameservers := resolvconf.GetNameservers([]byte(out), netutils.IP) |
|
1284 | 1284 |
if len(actualNameservers) != len(hostNamservers) { |
1285 | 1285 |
c.Fatalf("expected %q nameserver(s), but it has: %q", len(hostNamservers), len(actualNameservers)) |
1286 | 1286 |
} |
... | ... |
@@ -1311,11 +1312,11 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) { |
1311 | 1311 |
c.Fatalf("/etc/resolv.conf does not exist") |
1312 | 1312 |
} |
1313 | 1313 |
|
1314 |
- hostNamservers = resolvconf.GetNameservers(resolvConf) |
|
1314 |
+ hostNamservers = resolvconf.GetNameservers(resolvConf, netutils.IP) |
|
1315 | 1315 |
hostSearch = resolvconf.GetSearchDomains(resolvConf) |
1316 | 1316 |
|
1317 | 1317 |
out, _ = dockerCmd(c, "run", "busybox", "cat", "/etc/resolv.conf") |
1318 |
- if actualNameservers = resolvconf.GetNameservers([]byte(out)); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 { |
|
1318 |
+ if actualNameservers = resolvconf.GetNameservers([]byte(out), netutils.IP); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 { |
|
1319 | 1319 |
c.Fatalf("expected '12.34.56.78', but has: %v", actualNameservers) |
1320 | 1320 |
} |
1321 | 1321 |
|