gpt4 book ai didi

docker - 构建docker镜像导致大小增加一倍

转载 作者:行者123 更新时间:2023-12-02 19:25:50 26 4
gpt4 key购买 nike

因此,我试图通过使用多阶段构建过程来制作最小的图像,并且全部解决了,但是图像大小似乎不对。

最终镜像的docker历史记录输出

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 john@example.com 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

我在 adduser 步骤中期待更多字节,但没有42.1MB,好像我做了两次复制步骤一样

最佳答案

您正在更改上一步中复制到容器中的所有文件。对于Docker来说,这些都是全新文件,因此您得到的大小是预期的两倍。

复制文件时,请尝试使用COPY --chown=cgrates:cgrates . /cgrates/cgr-engine更改所有者,以防止这种情况。同样,您需要先创建用户,然后才能复制文件。

关于docker - 构建docker镜像导致大小增加一倍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56304341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com