Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image size difference in multistage builds by kaniko and docker #2768

Closed
jaskeerat789 opened this issue Sep 29, 2023 · 1 comment
Closed
Labels
area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) differs-from-docker issue/bigger-image-than-docker kind/friction priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy

Comments

@jaskeerat789
Copy link

jaskeerat789 commented Sep 29, 2023

Actual behavior
The image size of a multistage image build by docker is very large as compared to docker. Kaniko might not be discarding builder stage image. This is an initial hunch. I am using kaniko with Gitlab CI running on EKS cluster.

Expected behavior
The image size build by kaniko should be similar to that of image built by docker

To Reproduce
Steps to reproduce the behavior:

  1. Build the following Dockefile locally
  2. Build the same Dockerfile using kaniko
  3. compare the size of images pushed to repo

Additional Information

  • Dockerfile
FROM <private centos image with java 8> AS builder
WORKDIR /builds

COPY . /builds/
RUN ./gradlew clean build

#################### Runner Image ######################## 
FROM amazoncorretto:8-alpine3.17
WORKDIR /home/app

COPY --from=builder /builds/build/libs/app.jar ./app.jar
COPY ./startApp.sh .

USER app-user
EXPOSE 8080

ENTRYPOINT ["/bin/ash"]
CMD ["startApp.sh"]
  • Build Context: Building a java application using gradle in first stage and using jar file built in the second stage
  • Kaniko Image: gcr.io/kaniko-project/executor:v1.15.0-debug
  • Difference in sizes. First one is built and pushed by kaniko whereas the second image was built and pushed by docker running locally on an intel macbook .

image

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
@aaron-prindle aaron-prindle added area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) differs-from-docker issue/bigger-image-than-docker kind/friction priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy labels Sep 29, 2023
@aaron-prindle
Copy link
Collaborator

Thank you for flagging this @jaskeerat789. This issue has been reported previously here:
#2261

Feel free to continue the conversation there, going to close this as a dupe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) differs-from-docker issue/bigger-image-than-docker kind/friction priority/p1 Basic need feature compatibility with docker build. we should be working on this next. priority/p2 High impact feature/bug. Will get a lot of users happy
Projects
None yet
Development

No branches or pull requests

2 participants