Open slayer opened 4 years ago
hmm this should not typically happen. Can you share your dockerfile.
Yes, actually it was happen when FROM
is not defined properly
Dockerfile
ARG IMAGE
FROM ${IMAGE}
and additional --build-arg IMAGE=${DOCKER_IMAGE}
solves the problem
but IMO error message can be more helpful
@tejal29 should I take a look at this ?
I also encountered the same problem. my dockerfile is
FROM debian as debian
RUN \
export DEBIAN_FRONTEND=noninteractive &&\
apt-get update &&\
apt-get install -qq bash-static
FROM golang:1.13-alpine as builder
WORKDIR /workspace
COPY / /workspace/
RUN CGO_ENABLED=0 go install .
FROM alpine
ENTRYPOINT ["/khronos/khronos"]
EXPOSE 8080
COPY --from=debian /bin/bash-static /khronos/bash
COPY --from=builder /go/bin/khronos /khronos/
@tejal29 should I take a look at this ?
Please do @Tazminia . Would appreciate any help here.
I also encountered the same problem. my dockerfile is
FROM debian as debian RUN \ export DEBIAN_FRONTEND=noninteractive &&\ apt-get update &&\ apt-get install -qq bash-static FROM golang:1.13-alpine as builder WORKDIR /workspace COPY / /workspace/ RUN CGO_ENABLED=0 go install . FROM alpine ENTRYPOINT ["/khronos/khronos"] EXPOSE 8080 COPY --from=debian /bin/bash-static /khronos/bash COPY --from=builder /go/bin/khronos /khronos/
maybe the following line is the reason?
FROM debian as debian
In my case,
it works after I change FROM composer as composer
to FROM composer to composerStage
I'm having the same problem. Using ARG reference in multi-stage seems to be the problem:
Dockerfile example:
FROM golang:1.15 as build ... ARG BASE_IMAGE=ghcr.io/ironpeakservices/iron-scratch/iron-scratch:1.0.1 FROM ${BASE_IMAGE} ...
Log:
INFO[0001] Retrieving image golang:1.15 panic: runtime error: index out of range [1] with length 1 goroutine 1 [running]: github.com/GoogleContainerTools/kaniko/pkg/executor.CalculateDependencies(0xc000690900, 0x2, 0x2, 0x334ef00, 0xc0007dec60, 0x0, 0x0, 0x0) /go/src/github.com/GoogleContainerTools/kaniko/pkg/executor/build.go:506 +0xfd4 github.com/GoogleContainerTools/kaniko/pkg/executor.DoBuild(0x334ef00, 0x1, 0x0, 0x0, 0xc00059a280) /go/src/github.com/GoogleContainerTools/kaniko/pkg/executor/build.go:584 +0x268 github.com/GoogleContainerTools/kaniko/cmd/executor/cmd.glob..func2(0x3336bc0, 0xc000156000, 0x1, 0xe) /go/src/github.com/GoogleContainerTools/kaniko/cmd/executor/cmd/root.go:109 +0x11c github.com/spf13/cobra.(*Command).execute(0x3336bc0, 0xc00004c100, 0xe, 0xe, 0x3336bc0, 0xc00004c100) /go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:846 +0x29d github.com/spf13/cobra.(*Command).ExecuteC(0x3336bc0, 0x0, 0x1b78c20, 0xc00005a2f8) /go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:950 +0x349 github.com/spf13/cobra.(*Command).Execute(...) /go/src/github.com/GoogleContainerTools/kaniko/vendor/github.com/spf13/cobra/command.go:887 main.main() /go/src/github.com/GoogleContainerTools/kaniko/cmd/executor/main.go:26 +0x2d
It would be very helpful if this could be fixed, since this seems to be the easiest solution to setup hardened production images as well as comprehensive debugging images with just one Dockerfile!
Sorry to say this, but in my case it was not a problem of Kaniko! I just did not properly specify the ARG in Dockerfile! In multi-layer Dockerfile the scope needs to be taken care of as described in the docs and a Stackoverflow article: https://stackoverflow.com/questions/53681522/multi-stage-dockerfile-arg-before-from-not-substituted https://docs.docker.com/engine/reference/builder/#arg https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
I encountered the same problem as well. In my case the problem was the FROM
statement:
FROM nginx as nginx
A workaround that helped in my case was to use a tagged image:
FROM nginx:latest as nginx
I have the same problem.
I'm using FROM composer as composer
The workaround mentioned by @dankeder worked, but I think this should be fixed.
is this still an issue? I'm happy to work on it
It is still happening. If you have multi-stage build and have this:
FROM golang as golang
kaniko fails with this error.
But this line:
FROM golang as builder
works fine
I'm still seeing this issue, even without multistage build. This is my Dockerfile, and I have tried the latest 1.18.0 and 1.9.1 (debug) images
FROM example.com/jammy-generic-build:1.0.0
MAINTAINER Ashish Jaiswal <ashish@enableit.dk>
WORKDIR /tmp
RUN apt-get update \
&& \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
pandoc \
texlive-xetex \
&& \
apt-get autoremove -y \
&& \
apt-get autoclean -y \
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN rm -fr /var/lib/apt/lists/*
Reproductible with : --build-arg "XX=YY" instead of : --build-arg XX=YY
Need to check slice size https://github.com/GoogleContainerTools/kaniko/blob/master/pkg/executor/build.go#L516