diff --git a/integration/container/create_test.go b/integration/container/create_test.go index 6c8a084e5b..364720d8ba 100644 --- a/integration/container/create_test.go +++ b/integration/container/create_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/integration/util/request" "github.com/docker/docker/internal/testutil" + "github.com/gotestyourself/gotestyourself/skip" ) func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) { @@ -91,3 +92,47 @@ func TestCreateWithInvalidEnv(t *testing.T) { }) } } + +// Test case for #30166 (target was not validated) +func TestCreateTmpfsMountsTarget(t *testing.T) { + skip.If(t, testEnv.DaemonInfo.OSType != "linux") + + defer setupTest(t)() + client := request.NewAPIClient(t) + + testCases := []struct { + target string + expectedError string + }{ + { + target: ".", + expectedError: "mount path must be absolute", + }, + { + target: "foo", + expectedError: "mount path must be absolute", + }, + { + target: "/", + expectedError: "destination can't be '/'", + }, + { + target: "//", + expectedError: "destination can't be '/'", + }, + } + + for _, tc := range testCases { + _, err := client.ContainerCreate(context.Background(), + &container.Config{ + Image: "busybox", + }, + &container.HostConfig{ + Tmpfs: map[string]string{tc.target: ""}, + }, + &network.NetworkingConfig{}, + "", + ) + testutil.ErrorContains(t, err, tc.expectedError) + } +}