Skip to content

Commit cba39a7

Browse files
committed
conformance: test non-root USER before WORKDIR
Add a test that checks who owns a WORKDIR if it's created after USER sets a non-root default runtime user. Signed-off-by: Nalin Dahyabhai <[email protected]>
1 parent f048370 commit cba39a7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

dockerclient/conformance_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,16 @@ func TestConformanceInternal(t *testing.T) {
458458
ContextDir: "testdata/multistage",
459459
Dockerfile: "Dockerfile.env",
460460
},
461+
{
462+
Name: "nonroot-USER-before-WORKDIR-used",
463+
ContextDir: "testdata/user-workdir",
464+
Dockerfile: "Dockerfile.used",
465+
},
466+
{
467+
Name: "nonroot-USER-before-WORKDIR-notused",
468+
ContextDir: "testdata/user-workdir",
469+
Dockerfile: "Dockerfile.notused",
470+
},
461471
}
462472

463473
for i, test := range testCases {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM alpine
2+
RUN adduser -D buildtest
3+
USER buildtest
4+
WORKDIR /workdir/created/deep/below
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM alpine
2+
RUN adduser -D buildtest
3+
USER buildtest
4+
WORKDIR /workdir/created/deep/below
5+
RUN ls -l /workdir

0 commit comments

Comments
 (0)