Using symlink in the RUN directive increases the image file size, but using Docker does not
Using symlink in the RUN directive increases the image file size, but using Docker does not
I'm trying to build an image where the RUN command in Dockerfile uses the ln -s operation, which eventually results in an increase in the size of the file layer, but using Docker does not increase the size of the file layer
FROM alpine
COPY my-binary /tmp/
RUN ln -s /tmp/my-binary /bin/my-binary
Actual behavior Using the docker history command to check the image history record, it is found that the file size of the last two layers of the image is 67.3MB, that is, the RUN command uses ln -s to increase the file size of the image layer
IMAGE CREATED CREATED BY SIZE COMMENT
82830d9d5280 292 years ago RUN ln -s /tmp/my-binary /bin/my-binary 67.3MB
<missing> 292 years ago COPY my-binary /tmp/ 67.3MB
<missing> 6 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B
<missing> 6 weeks ago /bin/sh -c #(nop) ADD file:aad4290d27580cc1a… 5.6MB
Expected behavior However, using the Docker command to build the image, this layer of file size does not increase. The last layer of the image is only 14B in size History is as follows
IMAGE CREATED CREATED BY SIZE COMMENT
66a6a74c8fce 27 minutes ago /bin/sh -c ln -s /tmp/my-binary /bin/my-bina… 14B
f14f3d5934d3 27 minutes ago /bin/sh -c #(nop) COPY file:8344ecdeecf3502a… 67.3MB
14119a10abf4 6 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B
<missing> 6 weeks ago /bin/sh -c #(nop) ADD file:aad4290d27580cc1a… 5.6MB
To Reproduce Steps to reproduce the behavior:
- ...
- ...
Additional Information
- Dockerfile Please provide either the Dockerfile you're trying to build or one that can reproduce this error.
- Build Context Please provide or clearly describe any files needed to build the Dockerfile (ADD/COPY commands)
- Kaniko Image (fully qualified with digest)
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 |
|
Hello, We're also facing the same issue. Is there any plan to resolve this in upcoming releases?