Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
The contents of Docker containers run directly on top of the host operating system, unlike a virtual machine where they run on top of a guest operating system. Eliminating that guest OS and emulated hardware makes Docker containers much more lightweight than virtual machines.
New Terms
- OS - Operating System, think Windows, MacOS/OS X, Linux (Ubuntu, RedHat, etc.)
- Emulation - When a system will replicate all the functionality of another system so that it’s transparent to the user what the underlying hardware is.
- Virtual Machine - an emulation of a computer system.
- Container - a lightweight isolated environment for an app or service to run.
Further Reading:
[MUSIC]
0:00
In the last stage we took a look at
what Docker is and why people use it.
0:04
In this stage we'll look at how Docker can
streamline your software development in
0:09
a bid way.
0:13
Long ago, developers had to install all of
their apps dependencies on the OS itself
0:15
before they could even
begin development work.
0:19
This may work for your purposes, but
when it comes time to let a team mate or
0:22
customer use your code,
there can be many problems.
0:26
It's not always easy to reproduce what
worked on your machine on their machine.
0:29
Then came virtual machines
which really save the day.
0:34
VMs essentially emulated entire computers
with in a developer's computer,
0:36
VMs were great because they allow
developers to install their app's
0:41
dependencies in a virtual machine
keeping it isolated from main OS.
0:46
In certain configurations and for
0:51
certain apps, they can even be faster
than running on native hardware.
0:52
But this isn't the case most of the time.
0:57
Because a virtual machine has
to emulate all the hardware and
0:59
firmware it runs on,
it can be slow to start up.
1:02
And VMs are slower to run
in most circumstances.
1:06
And because the images contain an entire
operating system including packages
1:08
an app may not need, the disk images
are big and impractical to distribute.
1:13
Despite these drawbacks, virtual
machines made it much easier to build
1:18
reproducible environments for apps to
run on, so they exploded in popularity.
1:22
And in 2010, a software project
named Vagrant came along,
1:27
that promised to automate
the creation of VMs.
1:31
Vagrant allowed developers to build
new VMs using a configuration file
1:33
that specified an OS and
software packages to install.
1:38
But Vagrant still suffered from
the imparent problem of virtual machines,
1:42
distributing applications was still
difficult, it wasn't practical to
1:47
pass the VM from developer to developer or
developer to customer.
1:51
Anyone who wanted to
work on Vagrant VM had
1:55
run the initial bill to
create their VM from scratch.
1:58
That was the situation when Docker and
the concept of containers arrived in 2013.
2:01
The contents of Docker
containers run directly on
2:06
top of the host operating system.
2:09
Unlike a virtual machine where they run
on top of a guest operating system.
2:10
Eliminating that guest OS and
emulated hardware
2:16
makes Docker containers much more
lightweight than virtual machines.
2:19
A Docker still offers many of the same
benefits of Virtual Machines,
2:23
because they're isolated in a container,
the services running in docker containers
2:27
can't interfere with each other,
or with services on the host.
2:31
Because there's no need for
a full guest OS,
2:35
docker containers offer
many benefits over VMs.
2:37
They start up faster,
because you don't have to wait for
2:40
a whole separate OS to load.
2:43
You can re-use systems
resources more efficiently.
2:45
A virtual machine, usually has to receive
some parts of the host resources and
2:48
can't release them when it's
not actively using them.
2:52
Docker containers can free
resources they are not using.
2:54
Containers can usually take of
the hard role in the host machine and
2:58
ways a VM can.
3:02
For example a VMK usually use the GPU
to run codes but a container is up
3:04
can make full use of it, and
there's less redundancy with containers.
3:09
Whereas VMs usually need the entire
guess OS in order to run successfully,
3:14
containers runs strip down versions of
the OS with unnecessary parts removed.
3:18
That means you can run more containers
on the same host than you can with VMs.
3:24
There's one limitation
you should be aware of.
3:27
Depending on the app you're running
a container may not be having faster than
3:31
a virtual machine.
3:34
Containers usually start up
faster than VMs though so
3:35
you'll still see a speed
benefit from switching.
3:38
Docker's architecture has significant
differences from traditional virtual
3:41
machine architecture.
3:45
Docker runs containers on top of light
weight virtualized environments without
3:47
fully virtualized in the home machine.
3:51
Because docker doesn't virtualizing
entire OS, it can run much quicker and
3:53
be far more affordable
than a traditional VM.
3:57
Both virtual machines and containers
run on top of a host operating system.
4:00
To run virtual machines, the host OS
runs software called a hypervisor.
4:05
A hypervisor manages the life cycle of
VMs, starting and stopping them as needed,
4:10
managing their resources and
keeping the whole
4:14
setup secure by isolating the VMs
from the host OS and from each other.
4:17
An entire guest operating system runs
within each virtual machine, and
4:21
your apps dependencies as well as the app
itself are run within the guest OS.
4:25
Contrast this with Docker,
4:30
where containers are run by
the Docker Daemon software.
4:32
Docker containers omit most of
the guest OS except for a few packages.
4:34
Meaning most of the container resources
are devoted to your apps dependencies and
4:39
the app itself.
4:43
Docker doesn't have to run
the entire guest OS to run an app,
4:44
it simply share the host resources
like processors, memory and
4:48
networking devices between each container.
4:51
Even better Docker does an exclusively
hold the resources of the host OS.
4:54
When resources are released from a
container other Docker containers can use
4:59
those same resources.
5:03
Rather than entire virtual machines,
it's simpler to think of containers of
5:05
very heavy processes which
the Docker components manage.
5:09
This is what makes Docker a faster and
better way to deploy absent services.
5:12
So that's how Docker containers
differ from virtual machines.
5:18
Up next we'll look at
the details of how Docker works.
5:21
You need to sign up for Treehouse in order to download course files.
Sign up