Reputation: 23
So, I was trying to make a minimal image by using the multi stage build process and all worked out but the image size seems wrong.
docker history output of the final image
IMAGE CREATED CREATED BY SIZE COMMENT
sha256:1d430f8b3479c874ceaf6f2a3082ee6c6e726fe22dcd1bf8d2c3cfbfe72468a0 About an hour ago /bin/sh -c #(nop) CMD ["-config_path" "/config"] 0B
sha256:c25fee5c87edeec529335df9daf093760c5d2e9fdda258005f9743605b0db26c About an hour ago /bin/sh -c #(nop) ENTRYPOINT ["/cgrates/cgr-engine"] 0B
sha256:e5ee2c63bccd8b5cd6b7caf2833c0c4ea54dafad5682225717009808d38222a0 About an hour ago /bin/sh -c #(nop) VOLUME [/config] 0B
sha256:2ddc0dd3af71acfab190544aa45711b3dbdb285124565196c1d05bfde3bde867 About an hour ago /bin/sh -c #(nop) USER cgrates 0B
sha256:45d1598dfdc1e732f75c015214a977fe70f7eb955709ec86b122c18c72574408 About an hour ago /bin/sh -c adduser -g '' -h /cgrates -u 1000 -D -s /sbin/nologin cgrates && chown -R cgrates:cgrates /cgrates 42.1MB
sha256:36832f92c349d9d8645fd6bd5a3437d9a07bca68c92307b802e90fb7f7cf2259 About an hour ago /bin/sh -c #(nop) COPY file:ed9cb788bbfeacad1ce67440fe6388609cf6c6d7df5be16d5a3145a74a3230ba in /cgrates/cgr-engine 42.1MB
sha256:c6ad53011db71285780f8032fcf0754db4007eb75a79edd4794fa6738cde0372 About an hour ago /bin/sh -c #(nop) LABEL author=john doe [email protected] desc=cgrates master/latest git version at time of build 0B
sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1 2 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:a86aea1f3a7d68f6ae03397b99ea77f2e9ee901c5c59e59f76f93adbb4035913 in / 5.53MB
I was expecting a few bytes more in the adduser step but not 42.1MB plus as if i did the copy step two times
Upvotes: 1
Views: 1128
Reputation: 583
You are changing all the files you copied in the container the step before. For Docker those are totally new files and so you get double the size you expected.
Try using COPY --chown=cgrates:cgrates . /cgrates/cgr-engine
to change the owner while you copy the files to prevent that. Also you need to create the user before you can copy the files.
Upvotes: 3