mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
Allow unset --entrypoint
in docker run
or docker create
This fix tries to address the issue raised in #23498 to allow unset `--entrypoint` in `docker run` or `docker create`. This fix checks the flag `--entrypoint` and, in case `--entrypoint=` (`""`) is passed, unset the Entrypoint during the container run. Additional integration tests have been created to cover changes in this fix. This fix fixes #23498. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@ -478,3 +478,31 @@ func (s *DockerSuite) TestCreate64ByteHexID(c *check.C) {
|
||||
|
||||
dockerCmd(c, "create", imageID)
|
||||
}
|
||||
|
||||
// Test case for #23498
|
||||
func (s *DockerSuite) TestCreateUnsetEntrypoint(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
name := "test-entrypoint"
|
||||
dockerfile := `FROM busybox
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
RUN chmod 755 /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD echo foobar`
|
||||
|
||||
ctx, err := fakeContext(dockerfile, map[string]string{
|
||||
"entrypoint.sh": `#!/bin/sh
|
||||
echo "I am an entrypoint"
|
||||
exec "$@"`,
|
||||
})
|
||||
c.Assert(err, check.IsNil)
|
||||
defer ctx.Close()
|
||||
|
||||
_, err = buildImageFromContext(name, ctx, true)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
out, _ := dockerCmd(c, "create", "--entrypoint=", name, "echo", "foo")
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(id, check.Not(check.Equals), "")
|
||||
out, _ = dockerCmd(c, "start", "-a", id)
|
||||
c.Assert(strings.TrimSpace(out), check.Equals, "foo")
|
||||
}
|
||||
|
Reference in New Issue
Block a user