Kaniko image is huge after using cache
Actual behaviour Using this command causes the final image to be almost 2times as large with cache as without it.
/kaniko/executor --context "${DOCKER_CONTEXT_DIR}" --dockerfile "${DOCKER_FILE}" --destination $CONTAINER_REPO:$CONTAINER_TAG $build_args --cache=true --cache-repo "${DOCKER_REGISTRY}/${DOCKER_ORG}/${CONTAINER_CACHE_TAG}"
The first run with Kankio with the given command generates an image that is 3.7 GB in size and takes approx 34mins to run. The second run hits the cache 100% of the time and finishes in about 7mins. Thereafter the image upload takes approx 60mins and generates an image that is 6.7GB in size.
Expected behaviour Image size should be the same as with the first run i.e. 3.7GB but should be faster with 100% cache hits and uploads should take the same amount of time it did during the first run i.e. approx 10mins
To Reproduce Steps to reproduce the behaviour:
/kaniko/executor --context "${DOCKER_CONTEXT_DIR}" --dockerfile "${DOCKER_FILE}" --destination $CONTAINER_REPO:$CONTAINER_TAG $build_args --cache=true --cache-repo "${DOCKER_REGISTRY}/${DOCKER_ORG}/${CONTAINER_CACHE_TAG}"
Additional Information Unfortunately, I can not provide the Dockerfile as it pulls files from within our internal git repo. But it is very complex. Buildah builds the image in approx 12mins without cache and in approx 7mins with cache and is faster at uploads and doesn't bloat the 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 |
|
Seeing the same behavior. Would love to know what's going on here