Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Presentation - Docker - Monday, Week 9
Transcript of Presentation - Docker - Monday, Week 9
We're going to look at Docker, which is a bit different from Vagrant and traditional Virtual Machine usage.
Docker is different from other VMs
Based on LXC containers
A virtual machine boots < 1 second
Comes at a price
Not as isolated as a natural VM
Builds on a layered file system (Union Filesystem)
AUFS, btrfs, vfs, DeviceMapper
Say one machine has a 1GB base image
You want to create 1000 machines similar to that machine, with a tiny bit of customization (say 50 MB)
What you get is: 1GB + (0,05 GB x 1000) =
Instead of 1GB x 1000 + 0,05 GB x 1000 =
Basically - You build on
top of the base system
, only saving the
Read-only templates of virtual machines, these may come with everything integration. An example:
OS, running an
Apache HTTP Server
A repository for holding images, these may be public and private. An example of a public repository may be:
Running instances of Images
Create Script and build
A server / host
Runs the Docker daemon, responsible for managing and running containers.
Used to talk to the server / host
Easy to do!
... if we were running
Linux on our host / server
But we're running
Layer of Indirection
We need a Linux host, running Docker, which we can remote-control.
When you create a Container, a number of namespaces are created to separate running Containers from each other:
namespace: Process Isolation
namespace: Network Isolation
namespace: InterProcess Communication
namespace: Mount Points
namespace: Isolates Kernel and Version Identifiers
... are applied to each container.
These are basically ways to say:
You're allowed to consume this and this much...
Union File Systems
The layering mechanism of the data making up the containers.
The format the Container is running, there are 2 choices (for now):
Boot2Docker to the rescue!
Pull an Image from the Docker Hub:
sudo docker pull debian
Start a container
sudo docker run <image id>
Stop a container
sudo docker stop <container id>
... there are load more, read about them here:
Create (write and build) a Docker Image
Start from a base ubuntu image
Configure the Image to contain NodeJS
Configure the Image to have a shared folder with the NodeJS script from last week (helloworld nodejs app)
Expose a port, so you can interact with the NodeJS server - basically, see it from a browser)
Make the NodeJS server start with the container
Run the container
Delete the container and image
When we communicate with Docker, we're now talking to one or more virtual machines running inside a virtual machine!
Storing Data in Containers
Containers are volatile, no persistent data can be held
When you shut down a container, everything you did to the containers file-system disappears
Are created to hold Data outside the Union Filesystem, and these volumes are persistent, sort of...
The following restrictions apply:
Volumes are initialized when a container is created
Data volumes can be shared and reused between containers
Changes to a data volume are made directly
Changes to a data volume will not be included when you update an image
Volumes persist until no containers use them
Mounting in Data from Filesystem
Files and directories from the Host filesystem can also be mounted in, without creating a Data container.
This is primarily used for mounting in source code for development / testing purposes. Not really used in production scenarios.
We'll get back to this, so please
When using Docker on Windows or Mac OSX, we can only access the
Because we're running on Windows or Mac OSX
If you want data containers that are
when they not in use any more -
Data Volume Containers
are the answer!
Documentation on mounting Data in Docker:
(but that's optional)
Images for Docker can be build from scripts
These Scripts are called
Their Contents are extremely easy to read
They're fast to build, because they're incremental to build
Important to know
Modifying steps in the script may result in an another layer of the image being put on top of the previous
That is why if one step fails, you can rebuild, and it will continue from the previous step that succeeded
The Base Image to build from (MUST be the first statement in the Dockerfile!).
Metadata of who is the maintainer of the file.
Setting environment variables, for when containers are run for the resulting Image.
A step that runs a command, and puts it in a new layer for the Image.
Creates a mount-point for an external data container.
A step that runs a command, but doesn't result in a new layer for the Image. For instance, start the containers application.