TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How Containers Work: Overlayfs

582 pointsby saranshkover 5 years ago

13 comments

Cedricgcover 5 years ago
I enjoyed this blog post. Julia does a great job of distilling an idea down with examples.<p>I am fairly comfortable with Linux as a user for things like understanding processes, ports, key files and utilities, etc. The way I understand how to model abstractions like containers is to know the various OS primitives like cgroups, changing root, network isolation. Once one sees how those pieces come together to create the container abstraction, they can be mapped to the system calls provided by the OS. Usually they also have utilities bundled (like `chroot`) to interface with those primitives as an operator.
评论 #21571740 未加载
pcr910303over 5 years ago
Hmm... how is Overlayfs and Unionfs different? From the explanation I can&#x27;t find any differences...<p>Unionfs: A Stackable Unification File System[0]:<p>&gt; This project builds a stackable unification file system, which can appear to merge the contents of several directories (branches), while keeping their physical content separate.<p>&gt; Unionfs allows any mix of read-only and read-write branches, as well as insertion and deletion of branches anywhere in the fan-out.<p>&gt; To maintain unix semantics, Unionfs handles elimination of duplicates, partial-error conditions, and more.<p>If it is the same thing (but maybe more maintained or has more features...) , can we implement something like trip[1][2] package manager on top of Overlayfs?<p>(Porg is a package manager where all files that are installed by make install is tracked and mounted on a Unionfs layer.)<p>[0] <a href="http:&#x2F;&#x2F;unionfs.filesystems.org" rel="nofollow">http:&#x2F;&#x2F;unionfs.filesystems.org</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;grencez&#x2F;trip" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;grencez&#x2F;trip</a><p>[2] <a href="http:&#x2F;&#x2F;www.linuxfromscratch.org&#x2F;hints&#x2F;downloads&#x2F;files&#x2F;package_management_using_trip.txt" rel="nofollow">http:&#x2F;&#x2F;www.linuxfromscratch.org&#x2F;hints&#x2F;downloads&#x2F;files&#x2F;packag...</a>
评论 #21569226 未加载
评论 #21569899 未加载
评论 #21569202 未加载
nwellinghoffover 5 years ago
I recently made a system that uses overlays to provide work spaces for a complex build process. However, there is significant overhead paid for unmounting an deleting the files in the overlay after all the work is done. I was thinking about changing the system such that I allocate a partition ahead of time, write all the overlays there, and on success just blow away the partition and with it the overlays. This is kind of a pain in the ass. Can anyone suggest a method for rapidly deleting all the data generated by using 100&#x27;s of overlays? Maybe BtrFS snapshots would be better? What are the pros and cons? Thank you so much and I apologize for &quot;anything&quot; up front :)
评论 #21571792 未加载
评论 #21568430 未加载
评论 #21568863 未加载
评论 #21568549 未加载
dfoxover 5 years ago
I somehow feel compelled to point out that this idea of union&#x2F;overlay FS layers has nothing to do with containers per se. But on the other hand is somehow critical for why containers got popular as that is the way to make the whole thing somehow efficient both in terms of hardware resources and developer time.
评论 #21569927 未加载
评论 #21569890 未加载
评论 #21569218 未加载
评论 #21570986 未加载
评论 #21569904 未加载
2019119over 5 years ago
I wrote this script[1] a while ago which creates an overlay and chroots into the overlays workdir. It&#x27;s pretty useful, with it, you can do something like<p>&gt; overlay-here<p>&gt; make install (or .&#x2F;wierd-application or &#x27;npm install&#x27; or whatever)<p>&gt; exit<p>and all changes made to the filesystem in that shell is written to the upperdir instead. So for example in the above example, the upperdir would contain files such as upperdir&#x2F;usr&#x2F;bin&#x2F;app and upperdir&#x2F;usr&#x2F;include&#x2F;header.h.<p>It&#x27;s useful when<p>* You want to create a deb&#x2F;rpm&#x2F;tgz package, but a makefile does not have support for DESTDIR<p>* An application writes configuration files somewhere, but you don&#x27;t know where<p>* An application would pollute your filesystem by writing files in random places, and you want to keep this application local to &quot;this directory&quot;<p>* In general when you want to know &quot;which files does this application write to&quot; without resorting to strace<p>* or when you want to isolate writes, but not reads, that an application does<p>[1]: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;dbeecham&#x2F;183c122059f7ba288397e8c3320234d3" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;dbeecham&#x2F;183c122059f7ba288397e8c3320...</a>
评论 #21572682 未加载
评论 #21572330 未加载
ZoomZoomZoomover 5 years ago
There was a practice of using MergerFS&#x2F;OverlayFS for pooling multiple drives (often by SnapRAID users), but what&#x27;s still missing (to my knowledge) is some sort of a balancing layer, that could distribute writes.<p>I got this idea many years ago, when first personal cloud storages appeared and offered some limited space for free. I thought it would be nice if I could pool them and fill them taking their different capacities into account. And if I could also stripe and EC them for higher availability...<p>I still wonder if there&#x27;s something that can do this and if there isn&#x27;t I would like to know why, since it looks like a useful and obvious idea.
评论 #21572623 未加载
评论 #21571833 未加载
koffiezetover 5 years ago
This is crucial tech to understand docker-style containers...<p>I used this to build custom iso images based on an existing iso file. The old method mounted the ISO image, rsync&#x27;d the entire contents, copied and updated some files, and then created a new image. This took quite a while and (temporarily) wasted a lot of disk space, and was initially sped up by copying the temp ISO to RAM disk, which also presented some challenges, and wasn&#x27;t as fast as the eventual solution, using aufs on top of the ISO mount to patch the image. Worked like a charm and sped up the ISO building considerably :)
评论 #21591574 未加载
hackerm0nkeyover 5 years ago
Great article and nice style distilling all this into a bite size chunks.<p>Is it me or just the title is a little bit inaccurate in the sense that there&#x27;s more to &quot;How containers work?&quot; than overlays, e.g. it made me think that it covers more than it actually does, e.g. cgroups, namespaces, etc...<p>Anyone knows of a more in depth coverage of containers building block type of article that allows one to build a rudimentary container from scratch to appreciate what goes into building one ?
评论 #21569875 未加载
评论 #21569895 未加载
wooptooover 5 years ago
OverlayFS is pretty useful for day to day things like union folders for your media collection spanning across different hard drives. It does have a few quirks like inotify not working properly, so changes need to be watched for on the underlying fs.
marmadukeover 5 years ago
A lot of utility in Docker comes from incremental (cached) builds based on overlay but in fact you can get it from any CoW system such as LVM&#x2F;ZFS&#x2F;BtrFS snapshots.
评论 #21568317 未加载
评论 #21568916 未加载
评论 #21568540 未加载
评论 #21570708 未加载
z3t4over 5 years ago
When working with containers also consider hardware abstractions like virtual machines. Startup time can be optimez from minutes down to milliseconds. And also consider statically linked binaries if all you want is to solve the dll hell.
henesyover 5 years ago
s&#x2F;o to unionfs for plan9 by kvik: <a href="http:&#x2F;&#x2F;code.a-b.xyz&#x2F;unionfs" rel="nofollow">http:&#x2F;&#x2F;code.a-b.xyz&#x2F;unionfs</a><p>Userspace implementation of union directories with control of which half of the union made gets precedence for certain operations such as file creation, etc.
crtlaltdelover 5 years ago
used ovelayfs for an embedded linux project! great stuff!