I was confused also about the difference because for me also it shouldn't
be 1.6 GB but that's what "docker images" tells me. On dockerhub, it's
the
"compressed size" so maybe compression could explain this ?
For the 300 MB, you have to take into account how the docker images are
built. In the Dockerfile, each time you write a line, you create a layer.
One of the error you made was to write the Dockerfile as you would write an
installation procedure.
It's more readable, but if you make multiple modifications on the
filesystem, you store it each time. The most costly one in this case is "RUN
chown -R tomcat8:tomcat8 /var/lib/tomcat8" which just changes the owner on
230 MB worth of data, thus adding 230 MB of nearly identical data as a new
layer.
You can view the impact of each layer here
(you can also get a
html code to get a nice image for you repository).
Regards
2017-01-19 15:04 GMT+01:00 Vincent Massol <vincent(a)massol.net>et>:
Hi Denis,
On 18 Jan 2017, at 15:46, Denis GERMAIN
<dt.germain(a)gmail.com> wrote:
Hi list,
Vincent Massol has asked for code review after official docker image
annoncement and though I am no Docker expert, I have found a few leads to
reduce image size and might have some suggestions to improve it.
With 3 little changes I have gained about 500 MB, but I still have to
make
sure everything still works.
- 200 of those MB where gained by a commonly used trick : adding
"--no-install-recommends" option to apt-get.
Some packages that are commonly installed with libreoffice might have
been
skipped and I still have to determine if it's
OK or not.
- The other 300 MB are safe. Most of it comes from "RUN chown -R
tomcat8:tomcat8 /var/lib/tomcat8" being moved inside the same layer as
the
curl xwiki.war && unzip.
This is great! Thanks so much for reviewing it and proposing ideas :)
For my knowledge, could you explain quickly how this wins 300MB (it seems
magical :))?
Also, the image take “only” 900MB (see
https://hub.docker.com/r/
xwiki/xwiki-mysql-tomcat/tags/) so I don’t understand why it takes 1.6GB
for you.
Thanks a lot
-Vincent
docker images
REPOSITORY TAG IMAGE
ID CREATED SIZE
xwiki-mysql-tomcat after
b05844c94dd0 7 seconds ago 1.157 GB
xwiki-mysql-tomcat before
174d549368d5 2 hours ago 1.689 GB
As soon as I have checked this works, I'll do a pull request.
In the meantime, code is online on
https://github.com/zwindler/docker-xwiki-1/tree/clear_apt
Regards
Denis GERMAIN