Containers For People in A Hurry
Containers For People in A Hurry
VM is a complete
inside, adding it to ZIP archive and
distributing it further. Sure, you
Operating System are guaranteed that all
dependencies are there (they're
with your App being ZIPPED after all!) but whoever
part of it wants to run it has to bootstrap
the whole OS (yes, that includes
that famous Windows startup
sound as well!). It's bulky!
Containers
It is absolutely possible to start a
container fully manually, without
are hard Docker and other stuff. But the
to
problem is that there's a lot you
need to take care of and it just
maintain takes away too much time.
Enthusiasts can google for "runc"
or "hcsshim" for Windows
containers.
Docker
provides a Platform for running
Containers. But if you go deep-
down, what it really does is takes that
pain away
orchestrates "dockerd", which in
turn talks to "runc" and ensures
that your containers are
bootstrapped and run properly.
introduced
Docker is concept of "Images" and
"Layers". We will talk more about
"Images" them in the future graphics, but
what you need to know is that,
before Docker, you always had to
pack EVERYTHING in your
Container Bundle. And distribution
was simply pain in the ass!
OCI
of Docker effort is Open Container
Initiative. OCI is a de-facto
specification
standard crafted by Docker & other
leaders in the field, that specifies a
format which you can use to
define, build & run containers on is born
any platform. What this means?
You're free to use whichever
solution you want, as long as you
conform to standards!
BitesizedEngineering.com
Open Container
Initiative
[ OCI explained ]
a Unit of
containers. They are supposed to
represent a BASIC UNIT OF A
Software SOFTWARE DELIVERY. Think of an
Delivery .EXE file runnable anywhere
(Windows, Linux, OSC, etc.) without
any additional requirements. That's
what Container is!
Specification
Windows app - one layer could be
Windows filesystem itself, and second
layer could be your app. When
rebuilding, you'd just change your App
Layer, while Windows one remains
cached.
BitesizedEngineering.com
"Container is not a VM"
[ and what it really means ]
vm container
Host OS
hardware hardware
can execute
execute it on Windows, because you need
Windows' kernel to run it. Same is true for Linux
on same OS apps - they can run only on boxes that have Linux
only
Kernel. In order to run Linux Containers on
Windows (aka LCOW), you need Linux's Kernel
and that's where VMs could jump in (i.e. start
Linux VM and execute containers on top of it).
BitesizedEngineering.com
Containers are like
The Truman Show
[ they think they are independent; and yet ]
I'm on my
container 1 own OS!
process a
I'm on my
container 2 own OS!
process b
Host OS Hahaha!
Containers
If you snoop around folders & files inside Container,
you'd be made to believe you have a full OS on your
own. It's actually an interesting task to figure out
think they are whether you are in a Container or on a full OS. Truth
is - they aren't. They are locked inside Host OS and
on their own it's the container runtime that proxies all the Kernel
stuff to Host OS to execute.
Use Hyper-V
to "how do I build stronger isolation". Instead of
having container communicate directly to Host
OS, it runs containers inside a specialized and
light-weight VM, along with its own Kernel. This
provides a way stronger isolation boundary,
mode for Strong
and at the same time this VM was made to be
able to use Host OS' resources, making it boot
Isolation
much faster.
On Linux: On Windows:
Service!
needed by Docker (and OCI in general)! It's the
MAIN PIECE OF PUZZLE that actually enables
Containers on Windows (COWs)!
containerd
manager available both for Windows and Linux
systems. It provides familiar APIs for Containers
to interact with. Fun fact: It was created for
Docker and then donated to OCI initiative!
BitesizedEngineering.com
Container
Networking
[ and how they communicate at all ]
1. Container Runtime
doesn't say anything
CNI about Networking and
how it should work!
Containe Plugin
r Runtime
2. That's where
Networking Specs
Jump In
Step 1 Step 2
Add
config
starts file
Network
Interface
BitesizedEngineering.com
Container Network
Interface (CNI)
[ make containers feel connected ]
Hello?
config
json
Container CNI
Runtime Framework
Commonly referred to as
"Infrastructure-as-a-Code", CNI outlines
Describe & a FRAMEWORK that allows you to
Apply
SPECIFY how you want your network to
look like (e.g. this many adapters, and
Approach have them bridged, and what not) and it
also gets called by Runtime in order to
do the actual work of APPLYING things
specified in config.
CNI Uses
just specifies the FORMAT in which
config (or manifest) has to be. After
that, it really relies on plugins, which are "Plugins" to
really just executable files that take do the dirty
config and container id on input and work
then it's up to them to actually DO the
network setup. It's quite flexible!
VERSION
DEL to remove it, CHECK to validate it
and VERSION returns CNI protocol
version being used. That's all there is!
BitesizedEngineering.com
What's inside the
Container Image?
[ penetrating the perimeter ]
Container
instance - a container. In case of
Windows Containers - that means
Windows OS + your executables!
"github/wagoodman/dive" is an amazing
graphical tool that you can use to literally
explore the contents of images.
Check out
Usecases are many - from sneak-peaking
to trying to compress the images. Try it
the "dive"
out! tool
You should know:
At this moment (January 2022), there are 15 Container Runtimes available
and not all of them are OCI compliant (e.g. Firecracker is not). Info that I
shared here is valid for those that ARE OCI compliant (Docker, containerd,
etc.) and for the rest feel free to look up their own docs. BitesizedEngineering.com
Inspecting Container
Image Content
[ and getting our hands dirty ]
The "HOW" Extract any image and you will find two files -
"oci-layout" and "index.json". Former is not
much interesting. It communicates to runtime
that this is an OCI compliant image, and
specifies which version is it. Latter one is way
more interesting! Index.json contains list of
Manifests (for mortals - simple config files in
JSON format) for each platform (Linux,
oci-layout & Windows, etc.) that describe how the container
index.json should behave. Google "OCI Image Index
Specification" for details!
The "WHAT"
Per OCI Image spec, there's another mandatory
folder - "blobs". And this one keeps the actual
interesting bits! Inside this folder you will find
bunch of FILES whose names are hashes of the
content itself (called "digests" but more on that
in future). These files are either TEXT files (i.e.
various Manifests) or actual .tar balls (e.g. a
ayer
W L
R/
Union
Your App
Mount!
A d ditio n al A pps
(google it!)
W in d o w s O S
Runtime Engine
provides bits and
pieces needed to
connect all the moving
Container parts for running
Runtime Engine containers!
Container
Runtime
Engine
provides the
interfaces they have to provide, what are
the standard errors, etc. This is a big thing
standard given that you can interchangably use
different runtimes and find the one that
suits you the best!
available at the
Container Runtimes to see the list of all
engines. Do keep in mind that each one
moment comes with some pros & cons and not all of
them are OCI compliant!
BitesizedEngineering.com
Why is Kubernetes?
[ also known as K8s ]
Running
one or two DBs, and eventually some
caching solution - life's good. You can
things on monitor, scale, upgrade and deploy by
Scale is HARD hand. But what if you had tens of
thousands or hundreds of thousands of
servers to take care of? Good luck doing
that by hand!
ubernetes
K
Con
iners tai
ta
Con urope in U ners
SA
in E
iners
ta
Con Asia
in
Container
Registry
(ACR, ECR,
GCR)
Image Image
Creator Consumer
BitesizedEngineering.com