Closed cmoulliard closed 2 years ago
The panic error is returned when /var/spool/mail
is processed by github.com/GoogleContainerTools/kaniko/pkg/util.mkdirAllWithPermissions
at line 776
func mkdirAllWithPermissions(path string, mode os.FileMode, uid, gid int64) error {
// Check if a file already exists on the path, if yes then delete it
info, err := os.Stat(path)
if !os.IsNotExist(err) && !info.IsDir() {
Logging Trace
TRAC[0001] symlink from spool/mail to /var/mail
TRAC[0001] creating dir /var/gopher
TRAC[0001] creating dir /var/preserve
TRAC[0001] creating dir /var/cache
TRAC[0001] creating dir /var/spool
TRAC[0001] creating dir /var/spool/mail
What is really strange is that we dont experiment such an error using the kaniko v1.7 image
FROM registry.access.redhat.com/ubi8-minimal
COPY ./hello.txt /workspace
LABEL "website.name"="geeksforgeeks website"
RUN microdnf install -y wget python3
and
docker run \
-v $(pwd)/workspace:/workspace \
gcr.io/kaniko-project/executor:latest \
--dockerfile /workspace/ubi8-minimal \
--context dir:///workspace/ \
--no-push
...
docker run \
-v $(pwd)/workspace:/workspace \
gcr.io/kaniko-project/executor:latest \
--dockerfile /workspace/ubi8-minimal \
--context dir:///workspace/ \
--no-push
INFO[0000] Retrieving image manifest registry.access.redhat.com/ubi8-minimal
INFO[0000] Retrieving image registry.access.redhat.com/ubi8-minimal from registry registry.access.redhat.com
INFO[0000] Built cross stage deps: map[]
INFO[0000] Retrieving image manifest registry.access.redhat.com/ubi8-minimal
INFO[0000] Returning cached image manifest
INFO[0000] Executing 0 build triggers
INFO[0000] Unpacking rootfs as cmd COPY ./hello.txt /workspace requires it.
INFO[0023] COPY ./hello.txt /workspace
INFO[0023] Taking snapshot of files...
INFO[0023] LABEL "website.name"="geeksforgeeks website"
INFO[0023] Applying label website.name=geeksforgeeks website
INFO[0023] RUN microdnf install -y wget python3
INFO[0023] Taking snapshot of full filesystem...
INFO[0023] cmd: /bin/sh
INFO[0023] args: [-c microdnf install -y wget python3]
INFO[0023] Running: [/bin/sh -c microdnf install -y wget python3]
...
Installing: wget;1.19.5-10.el8;x86_64;ubi-8-appstream
Complete.
INFO[0037] Taking snapshot of full filesystem...
...
INFO[0038] Skipping push to container registry due to --no-push flag
@cmoulliard The issues seems to be in alpine
image as a runner. It has /var/spool/mail -> /var/mail
symlink. And the ubi8-minimal
has symlink /var/mail -> spool/mail
. I think that while copying root FS cyclical symlink is creaded. The official kaniko image uses scratch
so it won't happen.
When I used alpine:3
(instead of scratch
) as a base for standard gcr.io/kaniko-project/executor
image it panics the same way.
When I used
alpine:3
(instead ofscratch
) as a base for standardgcr.io/kaniko-project/executor
image it panics the same way.
Can we then create an image using scratch where Dockerfile is defined as ?
FROM scratch
COPY --from=debugger /go/bin/dlv /usr/local/bin
COPY --from=builder /kaniko-app /kaniko-app
COPY --from=builder /go/src/kaniko-app/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN mkdir -p /kaniko /workspace /cache
WORKDIR /workspace
ENTRYPOINT ["/entrypoint.sh"]
Remark: Existing Dockerfile to build the kaniko build app is - https://github.com/redhat-buildpacks/poc/blob/cb7966371c4517a486280630950e0dbac477de73/kaniko/Dockerfile_build#L24-L35
@matejvasek
Merely updating FROM
clause won't work as for instance chmod
mkdir
or shell
is not present in scratch
image. But it should be doable somehow.
I can create PR for that.
FWIW I've had good luck with distroless/static
as the runner.
Issue
When we use a red hat
ubi8
image (= RHL OS), then the following error is reported by kaniko during the step to build the following dockerfileError