From 38569b9b9ac772da5d16d14a6e6f93738e0c939c Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 27 Aug 2018 17:48:18 -0700 Subject: [PATCH] dockerfile: never use entrypoint for run commands Signed-off-by: Tonis Tiigi --- frontend/dockerfile/dockerfile2llb/convert.go | 2 -- frontend/dockerfile/dockerfile_test.go | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index ab78d258..e947564a 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -572,8 +572,6 @@ func dispatchRun(d *dispatchState, c *instructions.RunCommand, proxy *llb.ProxyE var args []string = c.CmdLine if c.PrependShell { args = withShell(d.image, args) - } else if d.image.Config.Entrypoint != nil { - args = append(d.image.Config.Entrypoint, args...) } opt := []llb.RunOption{llb.Args(args)} for _, arg := range d.buildArgs { diff --git a/frontend/dockerfile/dockerfile_test.go b/frontend/dockerfile/dockerfile_test.go index 66cc8dcf..cc7e13f2 100644 --- a/frontend/dockerfile/dockerfile_test.go +++ b/frontend/dockerfile/dockerfile_test.go @@ -75,9 +75,39 @@ func TestIntegration(t *testing.T) { testPlatformArgsExplicit, testExportMultiPlatform, testQuotedMetaArgs, + testIgnoreEntrypoint, }) } +func testIgnoreEntrypoint(t *testing.T, sb integration.Sandbox) { + t.Parallel() + + dockerfile := []byte(` +FROM busybox +ENTRYPOINT ["/nosuchcmd"] +RUN ["ls"] +`) + + dir, err := tmpdir( + fstest.CreateFile("Dockerfile", dockerfile, 0600), + ) + require.NoError(t, err) + defer os.RemoveAll(dir) + + c, err := client.New(context.TODO(), sb.Address()) + require.NoError(t, err) + defer c.Close() + + _, err = c.Solve(context.TODO(), nil, client.SolveOpt{ + Frontend: "dockerfile.v0", + LocalDirs: map[string]string{ + builder.LocalNameDockerfile: dir, + builder.LocalNameContext: dir, + }, + }, nil) + require.NoError(t, err) +} + func testQuotedMetaArgs(t *testing.T, sb integration.Sandbox) { t.Parallel()