Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start 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

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Presentation - Docker - Monday, Week 9

Presentation given at EASV, in SDM on Docker (monday, week 9 - 2015).
by

Anders Skarby

on 23 February 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Presentation - Docker - Monday, Week 9

Docker
Today's Plan
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
Super fast
A virtual machine boots < 1 second
Comes at a price
Not as isolated as a natural VM
Layering
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) =
51 GB
Instead of 1GB x 1000 + 0,05 GB x 1000 =
1,05 TB

Basically - You build on
top of the base system
, only saving the
delta
!
Docker terminology
Images
Read-only templates of virtual machines, these may come with everything integration. An example:

An
Ubuntu
OS, running an
Apache HTTP Server

Registries
A repository for holding images, these may be public and private. An example of a public repository may be:

http://hub.docker.com

Containers
Running instances of Images
Hosting Data
Workflow
Pull
Image
from
Repository

Run
Container
with
Image

Create Script and build
Image

Run
Container
with
Image

Push
Image
to
Repository
Docker Architecture
Multi-tier:
A server / host
Runs the Docker daemon, responsible for managing and running containers.
A client
Used to talk to the server / host
Installing Docker
Easy to do!
Installing Docker
... if we were running
Linux on our host / server

But we're running
Windows
and
Mac OSX
!
Layer of Indirection
We need a Linux host, running Docker, which we can remote-control.
Namespaces
When you create a Container, a number of namespaces are created to separate running Containers from each other:

The
pid
namespace: Process Isolation
The
net
namespace: Network Isolation
The
ipc
namespace: InterProcess Communication
The
mnt
namespace: Mount Points
The
uts
namespace: Isolates Kernel and Version Identifiers
Control Groups
... are applied to each container.

These are basically ways to say:

You're allowed to consume this and this much...
Memory
Network
etc.
Union File Systems
The layering mechanism of the data making up the containers.
Container Format
The format the Container is running, there are 2 choices (for now):

libcontainer
lxc

Boot2Docker to the rescue!
http://boot2docker.io/
Boot2Docker
Boot2Docker
Docker Commands
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:
https://docs.docker.com/reference/commandline/cli/
Todays Assignments
Install Boot2Docker
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
Remember
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
EASV
Data Volumes
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.
Restrictions
We'll get back to this, so please
remind
me!
When using Docker on Windows or Mac OSX, we can only access the
"C:\Users\"
- and
"/Users/"
-directories
Because we're running on Windows or Mac OSX
If you want data containers that are
persistent
when they not in use any more -
Data Volume Containers
are the answer!
Documentation on mounting Data in Docker:
https://docs.docker.com/userguide/dockervolumes/
Start:
Start:
(but that's optional)
Building Images
Images for Docker can be build from scripts
These Scripts are called
Dockerfile
s
Their Contents are extremely easy to read
They're fast to build, because they're incremental to build
Example
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 Commands
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.
FROM

MAINTAINER
ENV

RUN

VOLUME
CMD
Full transcript