Skip to content
This repository has been archived by the owner. It is now read-only.

Make our container slimmer #425

Closed
andymckay opened this issue May 21, 2015 · 6 comments
Closed

Make our container slimmer #425

andymckay opened this issue May 21, 2015 · 6 comments

Comments

@andymckay
Copy link
Contributor

@andymckay andymckay commented May 21, 2015

 ~ $ docker history mozillamarketplace/solitude:latest
IMAGE               CREATED             CREATED BY                                      SIZE
f50827b510a3        5 hours ago         /bin/sh -c python /srv/solitude/bin/crontab/g   798 B
168ad93f67cc        5 hours ago         /bin/sh -c #(nop) ENV HISTCONTROL=erasedups     0 B
2172047d7d84        5 hours ago         /bin/sh -c #(nop) ENV HISTIGNORE=ls:exit:cd .   0 B
5db77155ecfd        5 hours ago         /bin/sh -c #(nop) ENV HISTSIZE=50000            0 B
f72763ab846a        5 hours ago         /bin/sh -c #(nop) ENV HISTFILE=/srv/solitude/   0 B
3b901754e6d6        5 hours ago         /bin/sh -c #(nop) EXPOSE 2602/tcp               0 B
19a31905244f        5 hours ago         /bin/sh -c #(nop) ENV SOLITUDE_DATABASE=mysql   0 B
3ae2ce2ec2b1        5 hours ago         /bin/sh -c cd /srv/solitude && git show -s --   7 B
e3bd6d47cba3        5 hours ago         /bin/sh -c #(nop) COPY dir:80a9700e42be3881fc   1.475 MB
e34d72146094        5 hours ago         /bin/sh -c peep install     --build /pip/buil   72.67 MB
f1aaacc03f8e        5 hours ago         /bin/sh -c pip install --no-deps --find-links   87.54 kB
1b4b8c84d479        5 hours ago         /bin/sh -c #(nop) WORKDIR /pip                  0 B
e3dea5d56be5        5 hours ago         /bin/sh -c #(nop) ADD dir:a3401d8869880d2d5ff   7.48 kB
5d1269ac6ea1        5 hours ago         /bin/sh -c mkdir -p /pip/{cache,build}          0 B
360e529bb331        5 hours ago         /bin/sh -c #(nop) ENV IS_DOCKER=1               0 B
acfb7a83f98c        5 hours ago         /bin/sh -c yum install -y cronie                34.72 MB
5d099af9ad32        5 hours ago         /bin/sh -c yum install -y bash-completion       18.68 MB
16bb922e5ff5        5 hours ago         /bin/sh -c yum install -y supervisor            224.5 MB
a921f723427c        8 months ago        /bin/sh -c yum install -y mysql-community-ser   375 MB
8ad265df9720        8 months ago        /bin/sh -c #(nop) ADD file:aef05b6e4bc0dc6ad7   144 B
e8bea049a4f1        8 months ago        /bin/sh -c pip install ipython ipdb             12.85 MB
36ffb00bde49        8 months ago        /bin/sh -c easy_install pip                     5.37 MB
cf917f76bec1        8 months ago        /bin/sh -c #(nop) ENV LD_LIBRARY_PATH=/opt/rh   0 B
03afde2a3cea        8 months ago        /bin/sh -c #(nop) ENV PATH=/opt/rh/python27/r   0 B
ceaa1c83f483        8 months ago        /bin/sh -c yum install -y libxslt               18.13 MB
c0c274ab3c92        8 months ago        /bin/sh -c yum install -y     python27-m2cryp   24.07 MB
c7231ca07c09        8 months ago        /bin/sh -c yum install -y gcc                   52.66 MB
9d6465866850        8 months ago        /bin/sh -c yum install -y git                   180.4 MB
01c25c4a6066        8 months ago        /bin/sh -c yum install -y python27              178 MB
42fbabc14120        8 months ago        /bin/sh -c #(nop) ADD file:6f87960d9923b0cb2b   123 B
68eb857ffb51        8 months ago        /bin/sh -c #(nop) ADD file:9be0e96ac5792a45d4   212.7 MB
34e94e67e63a        11 months ago       /bin/sh -c #(nop) MAINTAINER The CentOS Proje   0 B
511136ea3c5a        23 months ago                                                       0 B

git, python, supervisor and mysql-community-server are the biggest culprits

@andymckay
Copy link
Contributor Author

@andymckay andymckay commented May 21, 2015

RUN pip install supervisor
540868cb5bab        35 seconds ago      /bin/sh -c pip install supervisor               2.429 MB
RUN yum install -y supervisor
16bb922e5ff5        6 hours ago         /bin/sh -c yum install -y supervisor            224.5 MB
@andymckay
Copy link
Contributor Author

@andymckay andymckay commented May 21, 2015

Step 1 : RUN yum install -y supervisor
 ---> Running in e1b005663cc1
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.its.sfu.ca
 * extras: centos.les.net
 * libselinux: centos.les.net
 * updates: mirror.its.sfu.ca
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package supervisor.noarch 0:3.0b2-1 will be installed
--> Processing Dependency: python-meld3 >= 0.6.5 for package: supervisor-3.0b2-1.noarch
--> Processing Dependency: python-setuptools for package: supervisor-3.0b2-1.noarch
--> Running transaction check
---> Package python-meld3.noarch 0:0.6.10-1 will be installed
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch        Version              Repository        Size
================================================================================
Installing:
 supervisor             noarch      3.0b2-1              mozilla-mkt      608 k
Installing for dependencies:
 python-meld3           noarch      0.6.10-1             mozilla-mkt       62 k
 python-setuptools      noarch      0.6.10-3.el6         base             336 k

Transaction Summary
================================================================================
Install       3 Package(s)

Total download size: 1.0 M
Installed size: 4.0 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           516 kB/s | 1.0 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : python-setuptools-0.6.10-3.el6.noarch                        1/3 
  Installing : python-meld3-0.6.10-1.noarch                                 2/3 
  Installing : supervisor-3.0b2-1.noarch                                    3/3 
  Verifying  : python-meld3-0.6.10-1.noarch                                 1/3 
  Verifying  : python-setuptools-0.6.10-3.el6.noarch                        2/3 
  Verifying  : supervisor-3.0b2-1.noarch                                    3/3 

Installed:
  supervisor.noarch 0:3.0b2-1                                                   

Dependency Installed:
  python-meld3.noarch 0:0.6.10-1     python-setuptools.noarch 0:0.6.10-3.el6    

Complete!
@andymckay
Copy link
Contributor Author

@andymckay andymckay commented May 21, 2015

979526a526cd        2 minutes ago        /bin/sh -c yum install -y python27              265.1 MB

vs

002ef5b6cbdd        About a minute ago   /bin/sh -c yum install -y python27; yum clean   70.15 MB
@dklawren
Copy link

@dklawren dklawren commented May 21, 2015

You need to more command chaining in your Dockerfile RUN statements.

Example:

-RUN yum install -y supervisor
-RUN yum install -y bash-completion
-RUN yum install -y cronie
+RUN yum install -y supervisor bash-completion cronie && yum clean all

That is one of the drawbacks in the way an image is built is even though you so some clean up in a later RUN command, all the data is still in the final image no matter what due to change history. So any cleanup for a command needs to be in the same RUN command either as a shell script or by chaining them (&&).

dkl

@andymckay
Copy link
Contributor Author

@andymckay andymckay commented May 21, 2015

Yeah I'd heard that, its interesting:

Three installs, no clean:

392cecc77eae        12 hours ago         /bin/sh -c yum install -y cronie                34.72 MB
91154ebe69d8        12 hours ago         /bin/sh -c yum install -y bash-completion       18.67 MB
760d1b735093        12 hours ago         /bin/sh -c yum install -y supervisor            224.5 MB

Install and clean in one line:

23d486d7bc04        2 minutes ago        /bin/sh -c yum install -y supervisor bash-com   38.7 MB

Install and clean in three lines:

832fe193df7d        About a minute ago   /bin/sh -c yum install -y cronie && yum clean   34.69 MB
331bc45fc42a        About a minute ago   /bin/sh -c yum install -y bash-completion &&    18.64 MB
f74a8b922149        2 minutes ago        /bin/sh -c yum install -y supervisor && yum c   21.54 MB
@dklawren
Copy link

@dklawren dklawren commented May 21, 2015

Yeah that is strange that you get smaller size when doing each package individually. Had never tried that way as the all on one line is less typing :) There must be a reason for it but not worth it as 38.7 is still loads better than 224.5.

dkl

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants