Browse code

Remove ContainerUpdateCmdOnBuild, it does nothing.

Set a blank entrypoint to preserve the old behaviour.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2017/04/21 04:46:12
Showing 7 changed files
... ...
@@ -54,8 +54,6 @@ type Backend interface {
54 54
 	ContainerStart(containerID string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
55 55
 	// ContainerWait stops processing until the given container is stopped.
56 56
 	ContainerWait(containerID string, timeout time.Duration) (int, error)
57
-	// ContainerUpdateCmdOnBuild updates container.Path and container.Args
58
-	ContainerUpdateCmdOnBuild(containerID string, cmd []string) error
59 57
 	// ContainerCreateWorkdir creates the workdir
60 58
 	ContainerCreateWorkdir(containerID string) error
61 59
 
... ...
@@ -383,6 +383,11 @@ func run(req dispatchRequest) error {
383 383
 
384 384
 	logrus.Debugf("[BUILDER] Command to be executed: %v", runConfig.Cmd)
385 385
 
386
+	// Set blank entrypoint to cancel the entrypoint from the parent image
387
+	if len(runConfig.Cmd) > 0 {
388
+		runConfig.Entrypoint = strslice.StrSlice{""}
389
+	}
390
+
386 391
 	cID, err := req.builder.create(runConfig)
387 392
 	if err != nil {
388 393
 		return err
... ...
@@ -448,6 +448,7 @@ func TestRunWithBuildArgs(t *testing.T) {
448 448
 		getCacheFunc: func(parentID string, cfg *container.Config) (string, error) {
449 449
 			// Check the runConfig.Cmd sent to probeCache()
450 450
 			assert.Equal(t, cachedCmd, cfg.Cmd)
451
+			assert.Equal(t, strslice.StrSlice(nil), cfg.Entrypoint)
451 452
 			return "", nil
452 453
 		},
453 454
 	}
... ...
@@ -462,12 +463,14 @@ func TestRunWithBuildArgs(t *testing.T) {
462 462
 		// Check the runConfig.Cmd sent to create()
463 463
 		assert.Equal(t, cmdWithShell, config.Config.Cmd)
464 464
 		assert.Contains(t, config.Config.Env, "one=two")
465
+		assert.Equal(t, strslice.StrSlice{""}, config.Config.Entrypoint)
465 466
 		return container.ContainerCreateCreatedBody{ID: "12345"}, nil
466 467
 	}
467 468
 	mockBackend.commitFunc = func(cID string, cfg *backend.ContainerCommitConfig) (string, error) {
468 469
 		// Check the runConfig.Cmd sent to commit()
469 470
 		assert.Equal(t, origCmd, cfg.Config.Cmd)
470 471
 		assert.Equal(t, cachedCmd, cfg.ContainerConfig.Cmd)
472
+		assert.Equal(t, strslice.StrSlice(nil), cfg.Config.Entrypoint)
471 473
 		return "", nil
472 474
 	}
473 475
 
... ...
@@ -601,12 +601,6 @@ func (b *Builder) create(runConfig *container.Config) (string, error) {
601 601
 
602 602
 	b.tmpContainers[c.ID] = struct{}{}
603 603
 	fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
604
-
605
-	// override the entry point that may have been picked up from the base image
606
-	if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, runConfig.Cmd); err != nil {
607
-		return "", err
608
-	}
609
-
610 604
 	return c.ID, nil
611 605
 }
612 606
 
... ...
@@ -73,10 +73,6 @@ func (m *MockBackend) ContainerWait(containerID string, timeout time.Duration) (
73 73
 	return 0, nil
74 74
 }
75 75
 
76
-func (m *MockBackend) ContainerUpdateCmdOnBuild(containerID string, cmd []string) error {
77
-	return nil
78
-}
79
-
80 76
 func (m *MockBackend) ContainerCreateWorkdir(containerID string) error {
81 77
 	return nil
82 78
 }
... ...
@@ -22,20 +22,6 @@ func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostCon
22 22
 	return container.ContainerUpdateOKBody{Warnings: warnings}, nil
23 23
 }
24 24
 
25
-// ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.
26
-func (daemon *Daemon) ContainerUpdateCmdOnBuild(cID string, cmd []string) error {
27
-	if len(cmd) == 0 {
28
-		return nil
29
-	}
30
-	c, err := daemon.GetContainer(cID)
31
-	if err != nil {
32
-		return err
33
-	}
34
-	c.Path = cmd[0]
35
-	c.Args = cmd[1:]
36
-	return nil
37
-}
38
-
39 25
 func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) error {
40 26
 	if hostConfig == nil {
41 27
 		return nil
... ...
@@ -337,13 +337,13 @@ func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) {
337 337
 	name1 := "onbuildcmd"
338 338
 	name2 := "onbuildgenerated"
339 339
 
340
-	buildImageSuccessfully(c, name1, build.WithDockerfile(`
340
+	cli.BuildCmd(c, name1, build.WithDockerfile(`
341 341
 FROM busybox
342 342
 ONBUILD CMD ["hello world"]
343 343
 ONBUILD ENTRYPOINT ["echo"]
344 344
 ONBUILD RUN ["true"]`))
345 345
 
346
-	buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s`, name1)))
346
+	cli.BuildCmd(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s`, name1)))
347 347
 
348 348
 	result := cli.DockerCmd(c, "run", name2)
349 349
 	result.Assert(c, icmd.Expected{Out: "hello world"})