Kaniko executes Dockerfile instructions within the ci image

171 views Asked by At

I have copied the kaniko executor from the gcr.io/kaniko-project/executor:debug in our custom image, our ci image looks like below

FROM gcr.io/kaniko-project/executor:debug AS kaniko

FROM custom-registry/ubuntu:22.04

COPY --from=kaniko /kaniko/ /kaniko/
ENV SSL_CERT_DIR /kaniko/ssl/certs
ENV PATH $PATH:/usr/local/bin:/kaniko

.
. 
.
rest of the docker file

This is how I built my ci image. This ci image has aws cli also installed.

The problem is now when I use this ci image to execute the kaniko command /kaniko/executor --dockerfile=Dockerfile --verbosity info --insecure --skip-tls-verify --force --destination=custom-registry/app:v0.1 --context=./ The Dockerfile for app pulls the ubuntu base image & in addition to including the application dependencies it also installs aws cli as below

FROM custom-registry/ubuntu:22.04

RUN cd  /opt && \
    curl -sk "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
    ./aws/install 
.
.
rest of the app dockerfile

But now eventhough the ubuntu:22.04 doesn't have aws cli installed, kaniko command fails with aws cli already installed

 ./aws/install
Found preexisting AWS CLI installation: /usr/local/aws-cli/v2/current. Please rerun install script with --update flag

From what I understood, the RUN or any instruction in the Dockerfile is ran on the kaniko image directly. Why is this so? How can I bypass this & get it installed directly in the base image that I have configured in FROM instruction.

I am aware that kaniko's officialy recommendation is to use the kaniko executor image itself, but since due to our corporate policy I am compelled to use our own custom image.

0

There are 0 answers