Remove ContainerUpdateCmdOnBuild, it does nothing.

Set a blank entrypoint to preserve the old behaviour.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-04-20 15:46:12 -04:00
Родитель 3dcab28982
Коммит 97f8607164
7 изменённых файлов: 10 добавлений и 28 удалений

Просмотреть файл

@ -54,8 +54,6 @@ type Backend interface {
ContainerStart(containerID string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
// ContainerWait stops processing until the given container is stopped.
ContainerWait(containerID string, timeout time.Duration) (int, error)
// ContainerUpdateCmdOnBuild updates container.Path and container.Args
ContainerUpdateCmdOnBuild(containerID string, cmd []string) error
// ContainerCreateWorkdir creates the workdir
ContainerCreateWorkdir(containerID string) error

Просмотреть файл

@ -383,6 +383,11 @@ func run(req dispatchRequest) error {
logrus.Debugf("[BUILDER] Command to be executed: %v", runConfig.Cmd)
// Set blank entrypoint to cancel the entrypoint from the parent image
if len(runConfig.Cmd) > 0 {
runConfig.Entrypoint = strslice.StrSlice{""}
}
cID, err := req.builder.create(runConfig)
if err != nil {
return err

Просмотреть файл

@ -448,6 +448,7 @@ func TestRunWithBuildArgs(t *testing.T) {
getCacheFunc: func(parentID string, cfg *container.Config) (string, error) {
// Check the runConfig.Cmd sent to probeCache()
assert.Equal(t, cachedCmd, cfg.Cmd)
assert.Equal(t, strslice.StrSlice(nil), cfg.Entrypoint)
return "", nil
},
}
@ -462,12 +463,14 @@ func TestRunWithBuildArgs(t *testing.T) {
// Check the runConfig.Cmd sent to create()
assert.Equal(t, cmdWithShell, config.Config.Cmd)
assert.Contains(t, config.Config.Env, "one=two")
assert.Equal(t, strslice.StrSlice{""}, config.Config.Entrypoint)
return container.ContainerCreateCreatedBody{ID: "12345"}, nil
}
mockBackend.commitFunc = func(cID string, cfg *backend.ContainerCommitConfig) (string, error) {
// Check the runConfig.Cmd sent to commit()
assert.Equal(t, origCmd, cfg.Config.Cmd)
assert.Equal(t, cachedCmd, cfg.ContainerConfig.Cmd)
assert.Equal(t, strslice.StrSlice(nil), cfg.Config.Entrypoint)
return "", nil
}

Просмотреть файл

@ -601,12 +601,6 @@ func (b *Builder) create(runConfig *container.Config) (string, error) {
b.tmpContainers[c.ID] = struct{}{}
fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
// override the entry point that may have been picked up from the base image
if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, runConfig.Cmd); err != nil {
return "", err
}
return c.ID, nil
}

Просмотреть файл

@ -73,10 +73,6 @@ func (m *MockBackend) ContainerWait(containerID string, timeout time.Duration) (
return 0, nil
}
func (m *MockBackend) ContainerUpdateCmdOnBuild(containerID string, cmd []string) error {
return nil
}
func (m *MockBackend) ContainerCreateWorkdir(containerID string) error {
return nil
}

Просмотреть файл

@ -22,20 +22,6 @@ func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostCon
return container.ContainerUpdateOKBody{Warnings: warnings}, nil
}
// ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.
func (daemon *Daemon) ContainerUpdateCmdOnBuild(cID string, cmd []string) error {
if len(cmd) == 0 {
return nil
}
c, err := daemon.GetContainer(cID)
if err != nil {
return err
}
c.Path = cmd[0]
c.Args = cmd[1:]
return nil
}
func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) error {
if hostConfig == nil {
return nil

Просмотреть файл

@ -337,13 +337,13 @@ func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) {
name1 := "onbuildcmd"
name2 := "onbuildgenerated"
buildImageSuccessfully(c, name1, build.WithDockerfile(`
cli.BuildCmd(c, name1, build.WithDockerfile(`
FROM busybox
ONBUILD CMD ["hello world"]
ONBUILD ENTRYPOINT ["echo"]
ONBUILD RUN ["true"]`))
buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s`, name1)))
cli.BuildCmd(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s`, name1)))
result := cli.DockerCmd(c, "run", name2)
result.Assert(c, icmd.Expected{Out: "hello world"})