Live data from Hacker News

A 1 KB Docker Container

blog.quickmediasolutions.com

31–40 of 75 posts

Re: A 1 KB Docker Container

#31
post #13

The smallest useful container I know of is 129B. It was created to test how many containers docker can spin up while reducing the overhead of what was in the container itself. tianon/sleeping-beauty latest 2e8193709fa7 6 months ago 129B https://github.com/tianon/dockerfiles/tree/master/sleeping-b...

Interesting. Incidentally, > It was created to test how many containers docker can spin up What was the answer? I'd think on the order of 200-300 on a server with 64 GB of RAM. (Pure guess!)

I would expect a 64 gig machine to be able to host 200-300 VMs, and an order or two magnitudes more containers

Re: A 1 KB Docker Container

#33
post #3

Another example of a really small container that doesn't do much, but is made without using assembly directly is the Docker "hello-world". It's built from C without linking in libc: https://github.com/docker-library/hello-world/blob/master/he... I always thought this was a bit misleading. A "hello world" container is 1 kB, but the bare minimum container that does something useful in practice is rarely less than 100 M…

> but the bare minimum container that does something useful in practice is rarely less than 100 MB in size. I’ve made containers using code written in most common programming languages (python/go/ruby/c/rust/heck even PHP/etc) which were easily under 100mb, most significantly less. If your containers are frequently >100mb, I say you’re either using the JVM or are doing it wrong!

Actually, even the entire JVM is below 60MB without Jigsaw, with Jigsaw it can go as low as 10MB

Re: A 1 KB Docker Container

#34
post #31

Earlier quoted context omitted.

Interesting. Incidentally, > It was created to test how many containers docker can spin up What was the answer? I'd think on the order of 200-300 on a server with 64 GB of RAM. (Pure guess!)

I would expect a 64 gig machine to be able to host 200-300 VMs, and an order or two magnitudes more containers

I guess you don't have anything CPU intensive running.

General good practice for sysadmins is to affine CPU cores/threads so that you don't end up flushing the CPU cache too aggressively and you don't split your VM's over NUMA zones because memory locality is important.

Re: A 1 KB Docker Container

#35
Notice that the executable itself contains less than 100 bytes of instructions, but the file is still 736 bytes. Even without optimising the Asm itself (I can see at least 2-3 bytes improvement at a glance), that could probably be reduced even further:

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...

736B may seem tiny to most people, but if you're working in Asm that's a lot --- there's plenty of interesting things (beyond "call the OS a few times") the demoscene has done with smaller binaries; here's an assortment of 512B ones:

http://www.pouet.net/prodlist.php?type[]=512b

Re: A 1 KB Docker Container

#36
post #6
post #3

Another example of a really small container that doesn't do much, but is made without using assembly directly is the Docker "hello-world". It's built from C without linking in libc: https://github.com/docker-library/hello-world/blob/master/he... I always thought this was a bit misleading. A "hello world" container is 1 kB, but the bare minimum container that does something useful in practice is rarely less than 100 M…

If you base off alpine, you can get useful containers quite a lot smaller than 100MB. One example i use is an agent i deploy to kubernetes clusters to do some security scanning. The scripts are ruby and the image clocks in at 9MB compressed https://hub.docker.com/r/raesene/kaa-agent/tags/

On the same note I did a mariadb container that is ~12mb: https://hub.docker.com/r/jbergstroem/mariadb-alpine/

If you're into go, it's not too hard to get very small (https://gist.github.com/jbergstroem/680cb7db6f90319dcd7666f3...

Re: A 1 KB Docker Container

#37
post #23

Earlier quoted context omitted.

Alpine's package manager has the great property that you don't need to update the index in order to fetch a package IIRC; the whole `apt-get update && apt-get install && ` dance is quite tedious in debian-based Docker containers.

No, you still need to, but there's a compact syntax for it that will update and discard the index in a single 'add' command. It's unavoidable - somewhere some querying is happening in order map the package name/ver to a download link.

I find the haproxy (alpine) Dockerfile a great example on how to tender to container file-size. It uses the syntax you're referring to, temporary build virtuals (should be multistage today I guess) and static linking: https://github.com/docker-library/haproxy/blob/2d393f2b59824...

Re: A 1 KB Docker Container

#38
post #30

Reminded me of people making docker containers out of this: https://github.com/nemasu/asmttpd eg. https://hub.docker.com/r/0xff/asmttpd/ 7KB web server container.

Are there any non-academic reasons to do use such servers?

Re: A 1 KB Docker Container

#39
This is of course pretty pointless, I mean it's neat but all these tiny containers don't really do anything so it isn't much more than a cool trick.

However there is a great lesson to take from this: you can create single-binary but really useful containers for just a few MBs, which is nothing in practice for a usual sized server, an a lot more lightweight than usual containers based off Alpine or Ubuntu.

In fact I run my static websites using that: a small 8-ish MB statically compiled web server "written" (it's really just library glue) in Go.

Re: A 1 KB Docker Container

#40
post #39

This is of course pretty pointless, I mean it's neat but all these tiny containers don't really do anything so it isn't much more than a cool trick. However there is a great lesson to take from this: you can create single-binary but really useful containers for just a few MBs, which is nothing in practice for a usual sized server, an a lot more lightweight than usual containers based off Alpine or Ubuntu. In fact I r…

Do you put the static content into the container?
Post reply on HN