大网数据广告活动
服务器运维问答

How to reduce Docker image size

· 52CE 我爱测

I have container running GlassFish. When I tried commit a image , it became 14GB. Later, I deleted /tmp/ in the container which was 10GB and tried to commit a image, but still the image is 14GB. It seems that deleting files from …

问题原文

原帖链接 · user1726453 · CC BY-SA 3.0

I have container running GlassFish. When I tried commit a image , it became 14GB. Later, I deleted /tmp/ in the container which was 10GB and tried to commit a image, but still the image is 14GB. It seems that deleting files from the container is not reflected in the image size. How do I fix this issue?

社区高分解答

原帖链接 · Juan Antonio Galán Martínez · CC BY-SA 3.0

The problem that you might be facing is that removing files in a commit does not change the fact that the file was there in a previous image, so that previous image is still 14G.

Have a look at the "Layers" part in this article: http://woudenberg.io/reducing-docker-image-size/

To solve that issue you need to remove the things under /tmp/ within the original commit that generated them, so the image created as a result of that commit does not include them. That is easy when use dockerfiles but not sure if possible when creating images with commits.

Another thing you may be able to do is squash layers by exporting/importing the image.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。