Linux containers in a few lines of code
zserge.com
Linux containers in a few lines of code
1–10 of 87 posts
Re: Linux containers in a few lines of code
#2[0] https://github.com/p8952/bocker
[1] https://github.com/p8952/bocker/blob/master/bocker#L61-L90
Re: Linux containers in a few lines of code
#3Re: Linux containers in a few lines of code
#4isolation layer: the piece that limits privileges and resource usage. (On linux, this is usually handled by cgroups and the kernel, but could also be handled by something like kvm for vm-based containers)
raw container configuration: Given an image and some metadata (like cpu limits), launch an isolated process. (On linux, this is usually handled by runc when working with cgroups)
container api daemon: Manage the list of container processes and available images. Provide a unix socket based API for manipulating isolated processes, launching, deleting, connecting, etc. (In the case of docker, they provide a daemon which abstracts the containerd daemon, or you can use containerd alone without docker)
container command line tool: Provide a user/developer interface to the three things above. This is the docker command. When you install containerd without docker this is the ctr command.
Docker, which is probably the most famous container distribution, pairs the docker command with the docker daemon to abstract away the containerd daemon, runc, and cgroups.
If you use containerd alone, you get ctr/containerd/runc/cgroups.
There's a standalone command line tool (crictl) which replaces both ctr and docker and can be used on top of either the docker daemon or containerd.
[1] Container systems seem to have a relatively complex abstraction over what is a relatively simple architecture.
Re: Linux containers in a few lines of code
#5For me this is enough to get a container running:
lxd init
lxc launch ubuntu mycontainer
lxc exec mycontainer bash
https://linuxcontainers.org/Re: Linux containers in a few lines of code
#6Linux containers in 500 lines of code (2016) https://news.ycombinator.com/item?id=22232705
Re: Linux containers in a few lines of code
#7Re: Linux containers in a few lines of code
#8DIY Containers on Linux is probably a better term here given that Linux Containers is already heavily in use around the world and included in ubuntu by Canonical? For me this is enough to get a container running: lxd init lxc launch ubuntu mycontainer lxc exec mycontainer bash https://linuxcontainers.org/
Re: Linux containers in a few lines of code
#9I love minimal code like this as a way of really understanding how something works. The author is pretty consistent too - he's got some great projects like an ultra-minimal electron alternative: https://github.com/zserge/webview
I’ve personally been getting in to writing minimal code because I’ve grown frustrated with how simple tasks can result in complex code that’s difficult to maintain. Minimal code is easier to come back to. A 100 line script can be easier to understand than a 500 line script.
Re: Linux containers in a few lines of code
#10A similar snippet[1] exists for go, and it doesn't do anything particularly special either.
I don't know, maybe David beazley has altered my sense of what "from scratch" means.
[1] https://gist.github.com/lizrice/a5ef4d175fd0cd3491c7e8d71682...