Signed-off-by: Chun Chen <ramichen@tencent.com>
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/layer" |
| 10 | 10 |
"github.com/docker/docker/pkg/idtools" |
| 11 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 12 |
+ "github.com/docker/docker/runconfig" |
|
| 12 | 13 |
volumestore "github.com/docker/docker/volume/store" |
| 13 | 14 |
"github.com/docker/engine-api/types" |
| 14 | 15 |
containertypes "github.com/docker/engine-api/types/container" |
| ... | ... |
@@ -122,6 +123,9 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe |
| 122 | 122 |
if params.NetworkingConfig != nil {
|
| 123 | 123 |
endpointsConfigs = params.NetworkingConfig.EndpointsConfig |
| 124 | 124 |
} |
| 125 |
+ // Make sure NetworkMode has an acceptable value. We do this to ensure |
|
| 126 |
+ // backwards API compatibility. |
|
| 127 |
+ container.HostConfig = runconfig.SetDefaultNetModeIfBlank(container.HostConfig) |
|
| 125 | 128 |
|
| 126 | 129 |
if err := daemon.updateContainerNetworkSettings(container, endpointsConfigs); err != nil {
|
| 127 | 130 |
return nil, err |
| ... | ... |
@@ -486,3 +486,8 @@ func (d *Daemon) findContainerIP(id string) string {
|
| 486 | 486 |
} |
| 487 | 487 |
return strings.Trim(out, " \r\n'") |
| 488 | 488 |
} |
| 489 |
+ |
|
| 490 |
+func (d *Daemon) buildImageWithOut(name, dockerfile string, useCache bool, buildFlags ...string) (string, int, error) {
|
|
| 491 |
+ buildCmd := buildImageCmdWithHost(name, dockerfile, d.sock(), useCache, buildFlags...) |
|
| 492 |
+ return runCommandWithOutput(buildCmd) |
|
| 493 |
+} |
| ... | ... |
@@ -2320,3 +2320,15 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec |
| 2320 | 2320 |
c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads) |
| 2321 | 2321 |
c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads) |
| 2322 | 2322 |
} |
| 2323 |
+ |
|
| 2324 |
+func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) {
|
|
| 2325 |
+ err := s.d.Start("-b=none", "--iptables=false")
|
|
| 2326 |
+ c.Assert(err, check.IsNil) |
|
| 2327 |
+ s.d.c.Logf("dockerBinary %s", dockerBinary)
|
|
| 2328 |
+ out, code, err := s.d.buildImageWithOut("busyboxs",
|
|
| 2329 |
+ `FROM busybox |
|
| 2330 |
+ RUN cat /etc/hosts`, false) |
|
| 2331 |
+ comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", out, code, err)
|
|
| 2332 |
+ c.Assert(err, check.IsNil, comment) |
|
| 2333 |
+ c.Assert(code, check.Equals, 0, comment) |
|
| 2334 |
+} |
| ... | ... |
@@ -930,7 +930,15 @@ func getContainerState(c *check.C, id string) (int, bool, error) {
|
| 930 | 930 |
} |
| 931 | 931 |
|
| 932 | 932 |
func buildImageCmd(name, dockerfile string, useCache bool, buildFlags ...string) *exec.Cmd {
|
| 933 |
- args := []string{"build", "-t", name}
|
|
| 933 |
+ return buildImageCmdWithHost(name, dockerfile, "", useCache, buildFlags...) |
|
| 934 |
+} |
|
| 935 |
+ |
|
| 936 |
+func buildImageCmdWithHost(name, dockerfile, host string, useCache bool, buildFlags ...string) *exec.Cmd {
|
|
| 937 |
+ args := []string{}
|
|
| 938 |
+ if host != "" {
|
|
| 939 |
+ args = append(args, "--host", host) |
|
| 940 |
+ } |
|
| 941 |
+ args = append(args, "build", "-t", name) |
|
| 934 | 942 |
if !useCache {
|
| 935 | 943 |
args = append(args, "--no-cache") |
| 936 | 944 |
} |