DEV Community

Cover image for How are docker images built? A look into the Linux overlay file-systems and the OCI specification

How are docker images built? A look into the Linux overlay file-systems and the OCI specification

Nicola Apicella on April 21, 2020

It's impossible to work with docker containers without docker images. In this post I want to talk about what makes docker images possible: the ove...
Collapse
 
dtinth profile image
Thai Pangsakulyanont

Today I learned about OCI stuff (that is totally new to me) and what’s going on behinds the scene when I run docker build. At first I thought it was a complex, custom-made, Docker-specific stuff. The way you broke it down two ordinary Linux commands made it much clearer for me what’s going on… it doesn’t look as scary as I thought now.

Thanks for sharing!

Collapse
 
napicella profile image
Nicola Apicella

Thank you! Glad it helped :)

Collapse
 
nkolchenko profile image
Nikolay Kolchenko • Edited

1) *CLI examples aren't consistent. *

[2020-04-19 16:31:09] [ubuntu] [/tmp/overlay-example/layer-4]  
 pactvm > ls -la
Enter fullscreen mode Exit fullscreen mode

and then:

[2020-04-19 16:37:11] [ubuntu] [/tmp/overlay-example]  
> sudo umount /tmp/overlay-example/mount && rm -rf *
Enter fullscreen mode Exit fullscreen mode

Imaging that noob reads it and the very first question is "What's the pactvm??"
Another important point is that the simple CTRL+C, CTRL+V of commands isn't working.

the

cd /tmp/overlay-example

is missed. I can almost see how noob does just a

cd

and

rm -rf *

does the trick. Why not to put

rm -rf /tmp/overlay-example/*

?

To sum it up, the article explains a really nice concept.. but in a very inconsistent and dangerous way.
Thank you. :)

Collapse
 
pablooliva profile image
Pablo Oliva

I am not a newbie, or at least i do not consider myself one, and I was confused by pactvm... thinking it was some command that I had never seen before, but I was too lazy to do a search.

Collapse
 
napicella profile image
Nicola Apicella • Edited

It s my login name. I removed it from most of the commands but forgot to remove it from some. I m so used to see my terminal that way I do not even notice it anymore 😅

I removed it. Thanks for the feedback

Collapse
 
mattnguyengit profile image
Matt Nguyen

I think: sudo umount /tmp/overlay-example/mount && rm -rf .* --> ...&& rm -rf *

Collapse
 
napicella profile image
Nicola Apicella

Good catch, it was a typo. Thanks

Collapse
 
mattnguyengit profile image
Matt Nguyen • Edited

No big deal, at least it throws an error. Not sure the feelings if the typo were rm -rf /* :))

Thread Thread
 
napicella profile image
Nicola Apicella

Even if it was "/*" it would have thrown an error, unless you were running as root. Note that only the mount is sudo-ed and that privileges are not propagated to the other commands in the && condition. Try:

> sudo whoami && whoami
root
napicella

That being said, the boy scout rule applies: never run as root and never copy/paste random commands (especially the ones which require privilege escalation) without knowing what they do :)

Collapse
 
dwgillies profile image
Donald Gillies • Edited

One of the very early union file systems is Clearcase by Rational Software (now owned by IBM). A workspace is put together via a series of views (which are versioned software releases) overlaid upon one another. The software required modifying the Solaris Kernel and required very powerful CPUs to work well. You would make all your changes in the top layer and when it was time to commit you only had to specify what branch(es) to add those changes to - clearcase knew what had been changed.
en.wikipedia.org/wiki/Rational_Cle... .

Collapse
 
napicella profile image
Nicola Apicella

That's interesting, I did not know that! Thanks for sharing it :)

Collapse
 
gabyx profile image
Gabriel Nützi

Thanks for this article!

Collapse
 
alvarezgarcia profile image
Alvarez García

Amazing way of describing hard concepts.
Can I use this to create some slides for a talk?, of course giving the credits of the author.

Collapse
 
napicella profile image
Nicola Apicella

Hi, thanks. Sure, you can use it.