Live data from Hacker News

A 1 KB Docker Container

blog.quickmediasolutions.com

51–60 of 75 posts

Re: A 1 KB Docker Container

#51

We already have a portable container format for executables with no dependencies... It's called an ELF binary... Why would you even put a static binary in a container in the first place? I don't get it.

You still need to administer the box it runs on. Offloading that to others is often useful.

Re: A 1 KB Docker Container

#52

We already have a portable container format for executables with no dependencies... It's called an ELF binary... Why would you even put a static binary in a container in the first place? I don't get it.

You still need to administer the box it runs on. Offloading that to others is often useful.

I guess you mean something like Compose or Kubernetes. I think it's weird these things force you to use the docker runtime, personally. I would really love a more flexible definition in kubernetes of what a "resource to be ran" means. I know they support multiple container runtimes now, but what if I dont want a container runtime at all?

Nomad supports raw executables to be downloaded and scheduled, which is nice(https://nomadproject.io) but then again, kubernetes seems miles ahead in what it supports (autoscaling, volume claims, RBAC etc)

Otherwise, more traditional means of managing your services can be employed. I've got a lot of leverage out of systemd myself. Which by the way, supports all the features of a proper container runtime. You can namespace your executable, Chroot it, limit what devices it can access, etc, which is kinda awesome. Check out `man systemd.exec` and `man systemd.resource-control`

Re: A 1 KB Docker Container

#53

We already have a portable container format for executables with no dependencies... It's called an ELF binary... Why would you even put a static binary in a container in the first place? I don't get it.

I guess if you wanted to take advantage of the implicit cgroup that the process then becomes a part of? Of course you could set up such a cgroup without Docker, but maybe it's just more convenient in certain cases to use Docker for it to keep your deployment process more consistent.

Re: A 1 KB Docker Container

#54
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!)

The server hosting the article above is also running 38 other containers - databases, WordPress blogs, Jenkins (CI), Gogs (Git), etc. And it only has 4 GB of RAM.

Re: A 1 KB Docker Container

#55
post #44

Earlier quoted context omitted.

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...

5mb still sounds like a lot, considering you could squeeze Linux 1.3 on a 1.44 mb floppy with a (compressed) rootfs... I mean does the runtime really do that much more than a full (although old) os kernel and a C library/runtime and apps?

The entirety of Debian 0.97 (kernel, userspace, packages) fit on two floppies back in 1994 :P

Re: A 1 KB Docker Container

#56
post #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?

I've done this with a couple of applications, using something like fileb0x in the build process to convert the files into Go source which can then be compiled into the final executable.

Re: A 1 KB Docker Container

#58

Earlier quoted context omitted.

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...

Awesome example, thanks. We've been starting using different Dockerfiles for prod and dev. For prod we want tiny images, but for dev the caching of layers is more important for frequent rebuilds. Such balance all the time :sigh:

Re: A 1 KB Docker Container

#59
post #43
post #28

Earlier quoted context omitted.

Depends on several other variables. If you use default docker options, you'll be creating a veth pair per container. You might run into a limit there at around 1024 containers. You also might hit ulimit if your system isn't well configured. If you use --net=none, you won't hit that issue, and you'll probably be able to manage quite a few The resource usage ends up being roughly 4 bytes rss for the executable in the c…

What happens when you hit the limit? Thrashing swap or oom kills? (And what kind of overcommit policy did you use?)

I didn't hit any limit, but since I don't have swap it would likely be oom kills.

The first part of my post is speculating, the second part I ran an arbitrary number and observed resource usage to allow extrapolation, but didn't hit a limit.

Re: A 1 KB Docker Container

#60

As part of a competition before the last DockerCon I managed to get a container down to 69B Details: http://thebsdbox.co.uk/in-pursuit-of-a-tinier-binary-er/ Code: https://gist.github.com/thebsdbox/29e395299f89b52214b66269f5...

Nice.
Post reply on HN