Download presentation
Presentation is loading. Please wait.
1
Containers and Virtualisation
2
What is Virtualisation?
At its simplest – isolation from underlying hardware Hypervisors VMware Virtualbox Qemu Containers Linux Containers (LXC) Virtual Machine Applications Java Python
3
Why? Make better use of resources
Move workloads between physical systems Run multiple OS on the same hardware Create test environments
4
Hypervisors Host Operating System emulates machine hardware
Full OS sits on top of the hypervisor Can have different OS in each Virtual Machine Linux Windows OSX
5
Hypervisor VM 1 VM 2 VM 3 Applications Applications Applications
Guest OS Guest OS Guest OS Virtual Hardware Virtual Hardware Virtual Hardware Hypervisor Host OS Hardware
6
Containers Guest containers share the same kernel and parts of the OS
More efficient use of resources Only use what they require BUT can only run the same OS (Linux) Possible to have different distributions as longs as they are all running the same kernel
7
Host OS Kernel with Virtualisation Layer
Container Container 1 Container 2 Container 3 Applications Applications Applications Host OS Kernel with Virtualisation Layer Hardware
8
Container Advantages Uses less resource than a full VM
More containers for the same hardware Better use of resources If Container1 & Container2 open the same file: Host kernel open the file and reads page into Kernel page cache If both read from the same position, they just get given the same page
9
Linux Containers LXC LXC contains processes in the kernel
Provides Kernel namespaces ipc, uts, mount, pid, network and user Apparmor & SELinux Profiles Chroot (using pivot_root) Control Groups (cgroups) for resource isolation CPU, memory, block I/O, network, etc
10
LXC Components liblxc library Language bindings C, Python3, Ruby, etc
Userspace tools to control the containers
11
Using Containers Install apt-get install lxc Run
Create an Ubuntu type container called 'container1' # Create lxc-create -t ubuntu -n container1 # Start lxc-start -n container1 -d # Get info lxc-ls --fancy container1 # Stop lxc-stop -n container1 Start the container Stop the container
12
Docker Package containers into a portable format
Linux Only (uses Linux Containers) Share applications Private Between colleagues Public Docker Hub
13
Docker Components Docker Engine Applications Binaries Libraries App 1
Libs/Bins Libs/Bins Libs/Bins Docker Engine Host OS Hardware
14
Docker Images A read-only template for an application
Contains a series of layers Uses union file systems to combine layers into a single image Can be saved to a Docker Registry
15
Docker Image Layers Starts with a base image
Extended with Instructions Run a command Add a file or directory Create an environment variable Define processes to run on launch Can distribute just a change to a layer instead of an entire image
16
Docker Registries Registries contain Docker images Public or Private
Main public registry is the Docker Hub Huge collection of pre-built images that can be pulled down as a starting point to create your own image
17
Docker Containers The container holds everything needed for an application to run Created from an Image Can be Run Started Stopped Moved Deleted Isolated from each other and the rest of the system
18
Installing Docker Ubuntu 14.04 For other systems see
$ sudo apt-get update $ sudo apt-get install docker.io $ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io For other systems see
19
Hello World docker run <image name> <command>
$ sudo docker run ubuntu echo 'Hello World' Unable to find image 'ubuntu' locally Pulling repository ubuntu [ Downloading Image ] Hello World $ Docker has pulled a copy of the ubuntu image from the Docker Hub The container stops when the command exits
20
Running Docker $ sudo docker run -i -t ubuntu /bin/bash
We are now running bash inside our Ubuntu container -t creates a terminal inside the container -i connects to STDIN of the container for interactive connections
21
Creating our Own Image After we have made changes to an image, those changes need to be commited $ sudo docker run -i -t ubuntu /bin/bash apt-get install apache2 … exit $ sudo docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 93a2e27d4d49 ubuntu:latest /bin/bash 24 minutes ago Exited (0) naughty_shockley $ sudo docker commit -m="Installed Apache" -a="Ming" 93A2e27d4d49 ming/apache 6d575ecf604809cf5b84b719afe74ba9588c72e4fdacbf2ca833f77f52e27309 -m Commit message -a Name of creator 93A2e27d4d49 Container ID ming/apache Name of new Image
22
Connecting to our Container
$ sudo docker run -i -t -p 8080:80 ming/apache /bin/bash apache2ctrl start -p <host port>:<container port> Map a port from our host to a port in our container
23
Conclusion Containers are a lightweight means of virtualisation
BUT only on a Linux System Docker simplifies the management and distribution of containers
24
Resources www.docker.com The Project Website www.docker.com/tryit
A sandbox to play with docker commands and images
25
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.