Wednesday, March 9, 2016

Using containers insteads of VMs

Experimenting with Containers

Lately, instead of spinning up a full virtual machine to get some work done, I have bee experimenting with "container technologies", well, right now mainly is just "Docker"

I found out that it is possible to run a very lightweight container based on Ubuntu with a foot print of about 180M bytes. This is impressive considering a typical Ubuntu VM that I use for my web development work is usually about 8G bytes of disk space. LOL. Yeah, that is a big difference. Then I got an idea that may be I can strip down Ubuntu that I use to be a little bit more "skinny". While researching the topic, I ran into a result of CenturyLink's quest to find a smallest containers. This is where I ran into "Alpine Linux". The article said that the smallest foot-print is Alpine and it is about 5M bytes. When I read this part, I think to myself, "Wow, 5M bytes. Is it a type?" More research and it turned out that Alpine Linux already have several things on Docker Hub.

The following is my experiment to find out how big will the image be when I loaded it with all the Dev tools. Alpine's development package is called "alpine-sdk". It is really a meta-package which pulls down 52 separate packages. The total space is 184M bytes. You can see the detail in the following section.

Content of the "alpine-sdk" package when installed

reia@reia-G770:~/Devel/github/dockers/alpine-sdk$ sudo docker build -t alpine-sdk .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM alpine:latest
 ---> 70c557e50ed6
Step 2 : MAINTAINER Rei.A.aoyama@gmail.com
 ---> Running in 35a09d16c582
 ---> 12e6aff24b9a
Removing intermediate container 35a09d16c582
Step 3 : RUN apk update && apk upgrade && apk add alpine-sdk
 ---> Running in 1ab93c34ce4a
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
v3.3.1-126-g1d080b9 [http://dl-cdn.alpinelinux.org/alpine/v3.3/main]
v3.3.1-122-g47d8282 [http://dl-cdn.alpinelinux.org/alpine/v3.3/community]
OK: 5855 distinct packages available
OK: 5 MiB in 11 packages
(1/52) Installing fakeroot (1.20.2-r2)
(2/52) Installing sudo (1.8.15-r1)
(3/52) Installing pax-utils (0.9.1-r0)
(4/52) Installing openssl (1.0.2g-r0)
(5/52) Installing libattr (2.4.47-r4)
(6/52) Installing attr (2.4.47-r4)
(7/52) Installing tar (1.28-r1)
(8/52) Installing pkgconf (0.9.12-r0)
(9/52) Installing patch (2.7.5-r0)
(10/52) Installing ca-certificates (20160104-r2)
(11/52) Installing libssh2 (1.6.0-r1)
(12/52) Installing curl (7.47.0-r0)
(13/52) Installing abuild (2.25.0_rc1-r3)
Executing abuild-2.25.0_rc1-r3.pre-install
(14/52) Installing binutils-libs (2.25.1-r0)
(15/52) Installing binutils (2.25.1-r0)
(16/52) Installing gmp (6.1.0-r0)
(17/52) Installing isl (0.14.1-r0)
(18/52) Installing libgomp (5.3.0-r0)
(19/52) Installing libatomic (5.3.0-r0)
(20/52) Installing libgcc (5.3.0-r0)
(21/52) Installing pkgconfig (0.25-r1)
(22/52) Installing mpfr3 (3.1.2-r0)
(23/52) Installing mpc1 (1.0.3-r0)
(24/52) Installing libstdc++ (5.3.0-r0)
(25/52) Installing gcc (5.3.0-r0)
(26/52) Installing make (4.1-r0)
(27/52) Installing musl-dev (1.1.12-r2)
(28/52) Installing libc-dev (0.7-r0)
(29/52) Installing fortify-headers (0.7-r0)
(30/52) Installing g++ (5.3.0-r0)
(31/52) Installing build-base (0.4-r1)
(32/52) Installing expat (2.1.0-r2)
(33/52) Installing pcre (8.38-r0)
(34/52) Installing git (2.6.4-r0)
(35/52) Installing xz-libs (5.2.2-r1)
(36/52) Installing lzo (2.09-r0)
(37/52) Installing squashfs-tools (4.3-r2)
(38/52) Installing file (5.25-r0)
(39/52) Installing bzip2 (1.0.6-r4)
(40/52) Installing libbz2 (1.0.6-r4)
(41/52) Installing libcap (2.24-r1)
(42/52) Installing cdrkit (1.1.11-r2)
(43/52) Installing acct (6.6.2-r0)
(44/52) Installing lddtree (1.25-r1)
(45/52) Installing libuuid (2.27.1-r0)
(46/52) Installing libblkid (2.27.1-r0)
(47/52) Installing device-mapper (2.02.138-r0)
(48/52) Installing cryptsetup-libs (1.7.1-r0)
(49/52) Installing kmod (22-r0)
(50/52) Installing mkinitfs (3.0.2-r0)
Executing mkinitfs-3.0.2-r0.post-install
(51/52) Installing mtools (4.0.18-r1)
(52/52) Installing alpine-sdk (0.4-r3)
Executing busybox-1.24.1-r7.trigger
Executing ca-certificates-20160104-r2.trigger
OK: 184 MiB in 63 packages
 ---> 1d7cd1e6622e
Removing intermediate container 1ab93c34ce4a
Successfully built 1d7cd1e6622e
reia@reia-G770:~/Devel/github/dockers/alpine-sdk$ 
Result docker images with all the "alpine-sdk" installed is about 182M bytes. I include based Ubuntu 14.04 and based "alpine" Linux for your reference
reia@reia-G770:~/Devel/github/dockers/alpine-sdk$ sudo docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
alpine-sdk              latest              1d7cd1e6622e        6 minutes ago       181.3 MB
alpine                  latest              70c557e50ed6        7 days ago          4.798 MB
ubuntu                  latest              e17b56e5200a        12 days ago         188 MB
reia@reia-G770:~/Devel/github/dockers/alpine-sdk$ 

No comments:

Post a Comment