Docker image size not matching the container size after a commit

前端 未结 2 1941
栀梦
栀梦 2021-01-14 11:48

Recently I created a docker container from a centos base image which ran a jboss. Originally I had installed the jdk (and committed) which made the container bulky (about 85

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 12:45

    Answering my own question. It seems that docker keeps adding layer to the base image whenever one commits to the image. However little you make your container committing it to the base is going only to add a new layer over the existing image which is always going to inflate the image. The problem with this approach is when you make modifications and commit to the base image, you end up taking unwanted layers to the production. I can see no official way to merge the layers. But there seems to be some workarounds in this link. However, I just recreated everything from the base and committed only once which made the image size very close to the container size.

提交回复
热议问题