mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
IT for service/network name with '.', corrected libnetwork flag for DNS
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
This commit is contained in:
parent
02c9d48144
commit
da9eadb066
3 changed files with 33 additions and 9 deletions
|
@ -21,7 +21,7 @@ import (
|
||||||
runconfigopts "github.com/docker/docker/runconfig/opts"
|
runconfigopts "github.com/docker/docker/runconfig/opts"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
"github.com/docker/docker/volume"
|
"github.com/docker/docker/volume"
|
||||||
"github.com/docker/engine-api/types/container"
|
containertypes "github.com/docker/engine-api/types/container"
|
||||||
"github.com/docker/engine-api/types/network"
|
"github.com/docker/engine-api/types/network"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/libnetwork"
|
"github.com/docker/libnetwork"
|
||||||
|
@ -290,7 +290,7 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network) ([]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !container.HostConfig.NetworkMode.IsUserDefined() {
|
if !containertypes.NetworkMode(n.Name()).IsUserDefined() {
|
||||||
createOptions = append(createOptions, libnetwork.CreateOptionDisableResolution())
|
createOptions = append(createOptions, libnetwork.CreateOptionDisableResolution())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ func (container *Container) IpcMounts() []execdriver.Mount {
|
||||||
return mounts
|
return mounts
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateCommand(c *execdriver.Command, resources container.Resources) {
|
func updateCommand(c *execdriver.Command, resources containertypes.Resources) {
|
||||||
c.Resources.BlkioWeight = resources.BlkioWeight
|
c.Resources.BlkioWeight = resources.BlkioWeight
|
||||||
c.Resources.CPUShares = resources.CPUShares
|
c.Resources.CPUShares = resources.CPUShares
|
||||||
c.Resources.CPUPeriod = resources.CPUPeriod
|
c.Resources.CPUPeriod = resources.CPUPeriod
|
||||||
|
@ -591,7 +591,7 @@ func updateCommand(c *execdriver.Command, resources container.Resources) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateContainer updates resources of a container.
|
// UpdateContainer updates resources of a container.
|
||||||
func (container *Container) UpdateContainer(hostConfig *container.HostConfig) error {
|
func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error {
|
||||||
container.Lock()
|
container.Lock()
|
||||||
|
|
||||||
resources := hostConfig.Resources
|
resources := hostConfig.Resources
|
||||||
|
|
|
@ -1301,3 +1301,26 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
|
||||||
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "bar")
|
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "bar")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *check.C) {
|
||||||
|
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||||
|
dockerCmd(c, "network", "create", "-d", "bridge", "br.net1")
|
||||||
|
|
||||||
|
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c1.net1", "busybox", "top")
|
||||||
|
c.Assert(waitRun("c1.net1"), check.IsNil)
|
||||||
|
|
||||||
|
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c2.net1", "busybox", "top")
|
||||||
|
c.Assert(waitRun("c2.net1"), check.IsNil)
|
||||||
|
|
||||||
|
// ping first container by its unqualified name
|
||||||
|
_, _, err := dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
// ping first container by its qualified name
|
||||||
|
_, _, err = dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1.br.net1")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
// ping with first qualified name masked by an additional domain. should fail
|
||||||
|
_, _, err = dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1.br.net1.google.com")
|
||||||
|
c.Assert(err, check.NotNil)
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/docker/docker/pkg/mount"
|
"github.com/docker/docker/pkg/mount"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
|
"github.com/docker/libnetwork/netutils"
|
||||||
"github.com/docker/libnetwork/resolvconf"
|
"github.com/docker/libnetwork/resolvconf"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
@ -1258,13 +1259,13 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) {
|
||||||
c.Fatalf("/etc/resolv.conf does not exist")
|
c.Fatalf("/etc/resolv.conf does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostNamservers := resolvconf.GetNameservers(origResolvConf)
|
hostNamservers := resolvconf.GetNameservers(origResolvConf, netutils.IP)
|
||||||
hostSearch := resolvconf.GetSearchDomains(origResolvConf)
|
hostSearch := resolvconf.GetSearchDomains(origResolvConf)
|
||||||
|
|
||||||
var out string
|
var out string
|
||||||
out, _ = dockerCmd(c, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf")
|
out, _ = dockerCmd(c, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf")
|
||||||
|
|
||||||
if actualNameservers := resolvconf.GetNameservers([]byte(out)); string(actualNameservers[0]) != "127.0.0.1" {
|
if actualNameservers := resolvconf.GetNameservers([]byte(out), netutils.IP); string(actualNameservers[0]) != "127.0.0.1" {
|
||||||
c.Fatalf("expected '127.0.0.1', but says: %q", string(actualNameservers[0]))
|
c.Fatalf("expected '127.0.0.1', but says: %q", string(actualNameservers[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,7 +1281,7 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) {
|
||||||
|
|
||||||
out, _ = dockerCmd(c, "run", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf")
|
out, _ = dockerCmd(c, "run", "--dns-search=mydomain", "busybox", "cat", "/etc/resolv.conf")
|
||||||
|
|
||||||
actualNameservers := resolvconf.GetNameservers([]byte(out))
|
actualNameservers := resolvconf.GetNameservers([]byte(out), netutils.IP)
|
||||||
if len(actualNameservers) != len(hostNamservers) {
|
if len(actualNameservers) != len(hostNamservers) {
|
||||||
c.Fatalf("expected %q nameserver(s), but it has: %q", len(hostNamservers), len(actualNameservers))
|
c.Fatalf("expected %q nameserver(s), but it has: %q", len(hostNamservers), len(actualNameservers))
|
||||||
}
|
}
|
||||||
|
@ -1311,11 +1312,11 @@ func (s *DockerSuite) TestRunDnsOptionsBasedOnHostResolvConf(c *check.C) {
|
||||||
c.Fatalf("/etc/resolv.conf does not exist")
|
c.Fatalf("/etc/resolv.conf does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostNamservers = resolvconf.GetNameservers(resolvConf)
|
hostNamservers = resolvconf.GetNameservers(resolvConf, netutils.IP)
|
||||||
hostSearch = resolvconf.GetSearchDomains(resolvConf)
|
hostSearch = resolvconf.GetSearchDomains(resolvConf)
|
||||||
|
|
||||||
out, _ = dockerCmd(c, "run", "busybox", "cat", "/etc/resolv.conf")
|
out, _ = dockerCmd(c, "run", "busybox", "cat", "/etc/resolv.conf")
|
||||||
if actualNameservers = resolvconf.GetNameservers([]byte(out)); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 {
|
if actualNameservers = resolvconf.GetNameservers([]byte(out), netutils.IP); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 {
|
||||||
c.Fatalf("expected '12.34.56.78', but has: %v", actualNameservers)
|
c.Fatalf("expected '12.34.56.78', but has: %v", actualNameservers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue