Skip to content

Commit 98eab32

Browse files
committed
dockerfile: fix history config for EXPOSE instruction
Signed-off-by: CrazyMax <[email protected]>
1 parent 0ca6aba commit 98eab32

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

frontend/dockerfile/dockerfile2llb/convert_expose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func dispatchExpose(d *dispatchState, c *instructions.ExposeCommand, opt *dispat
4141
d.image.Config.ExposedPorts[p] = struct{}{}
4242
}
4343

44-
return commitToHistory(&d.image, fmt.Sprintf("EXPOSE %v", ps), false, nil, d.epoch)
44+
return commitToHistory(&d.image, fmt.Sprintf("EXPOSE %v", psp), false, nil, d.epoch)
4545
}
4646

4747
type portSpecs struct {

frontend/dockerfile/dockerfile_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3916,6 +3916,7 @@ COPY --from=base foo2 foo3
39163916
WORKDIR /
39173917
RUN echo bar > foo4
39183918
RUN ["ls"]
3919+
EXPOSE 2375 5000 1234/udp
39193920
`)
39203921

39213922
dir := integration.Tmpdir(
@@ -3962,7 +3963,7 @@ RUN ["ls"]
39623963
// this depends on busybox. should be ok after freezing images
39633964
require.Equal(t, 4, len(ociimg.RootFS.DiffIDs))
39643965

3965-
require.Equal(t, 7, len(ociimg.History))
3966+
require.Equal(t, 8, len(ociimg.History))
39663967
require.Contains(t, ociimg.History[2].CreatedBy, "lbl=val")
39673968
require.Equal(t, true, ociimg.History[2].EmptyLayer)
39683969
require.NotNil(t, ociimg.History[2].Created)
@@ -3978,6 +3979,9 @@ RUN ["ls"]
39783979
require.Contains(t, ociimg.History[6].CreatedBy, "RUN ls")
39793980
require.Equal(t, false, ociimg.History[6].EmptyLayer)
39803981
require.NotNil(t, ociimg.History[6].Created)
3982+
require.Contains(t, ociimg.History[7].CreatedBy, "EXPOSE [1234/udp 2375/tcp 5000/tcp]")
3983+
require.Equal(t, true, ociimg.History[7].EmptyLayer)
3984+
require.NotNil(t, ociimg.History[7].Created)
39813985
}
39823986

39833987
// moby/buildkit#5505

0 commit comments

Comments
 (0)