17/08/2021
CRICOS code 00025BCRICOS code 00025B
Copyright By PowCoder代写 加微信 powcoder
Updates: On-Campus Teaching&Learning
Cloud Computing
• Carry a mask with you at all times.
• Masks must be worn – indoors* even when physical distancing is possible (unless alone) and
outdoors if you cannot physically distance from others. This includes libraries, retail outlets,
buses, work spaces and research and teaching environments. Masks can be removed while
eating or drinking.
• Observe physical distancing of 1.5m to the extent possible and check-in to all buildings using
the Check In QLD codes.
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Re-cap Lectures 3
Cloud Computing
• Networking and Virtual Private Cloud
• Load Balancing
– What & Why Load Balancing
– Algorithms
– LB in Cloud Architecture
– LB in Distributed Systems
– LB in Network Communications
– LB in Cloud Product
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Cloud Computing
• Container
• What is Docker
• Basic concepts in Docker
– Layer architecture
– Containers
– Registry
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• A virtual machine (VM) is an emulation of a computer system.
• Virtual machines are based on computer architectures and provide
functionality of a physical computer: software, specialised hardware, or a
combination.
• System virtual machines: provide a substitute for a real machine.
• Process virtual machines
– are designed to execute computer programs in a platform-independent
environment.
– provide a high-level abstraction (a high-level programming language
abstraction)
– Example: Java virtual machine (JVM)
Revisit: Virtual Machines (VMs)
https://en.wikipedia.org/wiki/Virtual_machine
https://blog.netapp.com/blogs/containers-vs-vms/
Cloud Computing
Middle-ware
Application
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• VM could simulate almost anything:
– Hardware (vCPU, vRAM, vHDisk, vGPU, vNetwork, etc.)
– Software (Operating System: Ubuntu, CentOS, Windows Server)
– Each VM requires its own dedicated OS; Extra hardware and software
– Performance of VM is not very satisfied (slow to boot up)
– Migration between physical servers is not always smooth.
Virtual Machines (VM)
Cloud Computing
Infrastructure
Hypervisor
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Containers
Cloud Computing
• Containers offer a logical packaging mechanism in which
applications can be abstracted from the environment in which they
actually run.
• Completely isolated environments: services, network interfaces,
• Multiple containers running atop the OS kernel directly – far more
lightweight:
– share the OS kernel
– start much faster (in seconds)
– use a fraction of the memory (compared to booting an entire OS)
– one physical machine/server can run much more containers than VMs
Infrastructure
Hypervisor
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Infrastructure
Container Runtime
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
https://cloud.google.com/containers/
https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers 7
Can we run containers on the host that do not share the same kernel?
https://cloud.google.com/containers/
https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Before container:
– Chroot system call in 1979 and FreeBSD jails in 2000.
– Cgroups (2006, 2007) and namespaces (2002)
– Linux Containers (LXC) in 2008
• Containers virtualise at the operating system level
• Containerisation provides a clean separation of concerns:
– developers focus on their application logic and dependencies
– IT operations teams focus on deployment and management without
bothering with application details (e.g. specific software versions and
apps configurations).
Cloud Computing
https://cloud.google.com/containers/
Infrastructure
Hypervisor
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Infrastructure
Container Runtime
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
https://www.redhat.com/en/blog/history-containers
https://cloud.google.com/containers/
https://www.redhat.com/en/blog/history-containers
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Run Anywhere:
– Containers are able to run virtually anywhere, greatly easing development
and deployment:
on Linux, Windows, and Mac operating systems;
on virtual machines;
on a developer’s machine;
in data centres on-premises;
in the public cloud.
• Isolation:
– Containers virtualise hardware at the OS-level:
memory, storage,
network resources.
– Containers provide developers with a sandboxed view of the OS logically
isolated from other applications.
Why Containers?
Cloud Computing
https://cloud.google.com/containers/
Infrastructure
Hypervisor
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Infrastructure
Container Runtime
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
https://cloud.google.com/containers/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Features Containers Virtual Machines
Start-time In seconds In minutes
Disk Size Normally in MB GB
Efficiency Fast (close to native) Very slow
Runnable instances
(on one physical
More than 1k Normally 10+
Containers vs. Virtual Machines
Cloud Computing
https://cloud.google.com/containers/
Infrastructure
Hypervisor
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Infrastructure
Container Runtime
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
https://cloud.google.com/containers/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Container
• What is Docker
• Basic concepts in Docker
– Layer architecture
– Containers
– Registry
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
What is a “Docker”?
https://en.wikipedia.org/wiki/Stevedore
Cloud Computing
stevedore (/ˈstiːvɪˌdɔːr/), longshoreman, docker, or dockworker
https://en.wikipedia.org/wiki/Help:IPA/English
17/08/2021
CRICOS code 00025BCRICOS code 00025B
What is a “Docker”
https://en.wikipedia.org/wiki/Stevedore
Cloud Computing
• Cargo can be quickly packed at source of
production
• Cargo can be quickly shipped from A to B
• Cargo can be quickly unpacked at
destination
• Cargo is what it is after shipping
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Continuous Integration (CI): automated testing
• Continuous Delivery (CD): automated release
• Continuous Deployment: fully automated
Modern Development Practices – DevOps
Cloud Computing
plan code build test release deploy operate
Continuous Integration
Continuous Delivery
Continuous Deployment
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Docker is
– a job (literally),
– a company providing solutions to containerisation (Google’s LXD),
– a new implementation of container technologies.
• Some definitions:
– Docker is a container image that is a lightweight, stand-alone, executable
package of a piece of software that includes everything needed to run it: code,
runtime, system tools, system libraries, settings.
– Docker is an open platform for developing, shipping, and running applications
(official documentation). Simply, Docker is a tool deploy applications in a
sandbox (called containers) to run on the host operating system i.e. Linux,
Windows, Mac OSX, etc.
What is Docker
https://thenewstack.io/solomon-hykes-departs-from-
https://www.docker.com/what-container
Cloud Computing
https://en.wikipedia.org/wiki/Docker_(software)
Docker founders
https://thenewstack.io/solomon-hykes-departs-from-docker/
https://en.wikipedia.org/wiki/Docker_(software)
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Container
• What is Docker
• Basic concepts in Docker
– Containers
– Registry
– Layer architecture
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Basic Concepts – Docker Image
Cloud Computing
https://cloud.google.com/containers/
• Docker image is an object that contains
– an OS filesystem
– and one or more applications
• An image is a template that is readable only to build a container.
• An image is based on another image (base image) with some
additional customisation
– Example: an image that contains a complete ubuntu 18.04 (LTS)
operating system and apache web server
• Docker provides a very good mechanism to build images and can
even pull the existing images.
• There are heaps of resources on Docker Hub.
• Many software is released as Docker images, instead of software
https://cloud.google.com/containers/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• With Union FS (Union Filesystems), Docker is designed as a
layer-wise architecture.
• Union FS: create a union of (1) a list of lower directories – read
only (2) upper directory – reads and writes
• Each image will not be changed (read-only) after it has been
constructed – lower directories.
• Layer-wise architecture makes reuse and customization of
images much easier.
– Construct a new image based on the existing images by
adding new layers on top of the current layers.
– E.g. Ubuntu + Python + security patch
Images and Layers
https://blog.netapp.com/blogs/containers-vs-vms/
Cloud Computing
https://docs.docker.com/storage/storagedriver/
Writable Overlay
https://docs.docker.com/storage/storagedriver/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• Copy-on-write is a strategy of sharing and copying files for maximum efficiency.
• Example: after constructing two layers, three files in Layer 1 and three files in Layer 2.
• What will happen if we want to update “File 5” in Layer 2
Copy-on-write Strategy: Example of Updating Files
Cloud Computing
https://docs.docker.com/storage/storagedriver/#the-copy-on-write-cow-strategy
https://docs.docker.com/storage/storagedriver/#the-copy-on-write-cow-strategy
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• “File 7” in layer 3 is an updated version of “File 5”
• Due to read-only property of each layer, “File 5” is
still stored in the image.
• “File 5” is updated as a new layer added into the
• Good practice:
– only add required files or apps in the current
– Temporary or redundant files must be removed
from the current layer before constructing the
next layer
– Very important when writing dockerfiles.
Copy-on-write Strategy: Example of Updating Files
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Basic Concepts – Container
Cloud Computing
https://stackoverflow.com/questions/2885385/what-is-the-difference-between-an-instance-and-an-object
• Container: a running instance of an image
– Class vs Instances (in Objective Oriented Programming)
– E.g. House Blueprints vs House
• Container is a running process
– Independent namespace
E.g. variable $JAVA_HOME in Container A is different from
$JAVE_HOME in Container B
– Independent root filesystem
E.g. /usr/local in Container A is different from /user/local in
Container B
– Independent networks
E.g. 192.168.0.1 in Container A is different from
192.168.0.1 in Container B
– Independent user space
E.g. user “John” in Container A is different from “John” in
Container B, even user root is different.
https://stackoverflow.com/questions/2885385/what-is-the-difference-between-an-instance-and-an-object
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Basic Concepts – Docker Registry
Cloud Computing
• After releases of docker images, a registry is needed to store and manage images for sharing.
• Docker images are stored in a Docker registry:
– Public Docker registry: Docker Hub and Google Container Registry
– Private Docker registry.
• Each Docker registry can have multiple repositories and each repository can have multiple tags. Each
tag corresponds to an image:
–
– Example: for ubuntu images – ubuntu:16.04 vs ubuntu:18.04
– Tags can be ignored (ubuntu -> ubuntu:latest)
• Registry’s name is normally represented by a path with two components (user/software)
– Example: docker pull microsoft/cntk:2.2-cpu-python3.5
https://hub.docker.com/
https://cloud.google.com/container-registry/ 22
can we keep images private in the public registry?
https://hub.docker.com/
https://cloud.google.com/container-registry/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Cloud Computing
• Container
• What is Docker
• Basic concepts in Docker
– Layer architecture
– Containers
– Registry
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Diagram – Image management
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• List images:
docker images [OPTIONS] [REPOSITORY[:TAG]]
• Remove one or more image:
docker rmi [OPTIONS] IMAGE [IMAGE…]
• Create a tag TARGET_IMAGE that refers to
SOURCE_IMAGE
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
• Show the history of an image
docker history [OPTIONS] IMAGE
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Diagram – Container management
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• Kill/Stop one or more running containers:
docker container kill/stop [OPTIONS] CONTAINER
[CONTAINER…]
docker kill/stop [OPTIONS] CONTAINER [CONTAINER…]
• Start one or more stopped containers:
docker container start [OPTIONS] CONTAINER
[CONTAINER…]
• Pause/Unpause all processes within one or more
containers
docker container pause/unpause [OPTIONS] CONTAINER
[CONTAINER…]
• Other container management commands
List containers: docker ps
Attach containers: docker attach [OPTIONS] CONTAINER
Run a bash: docker exec [OPTIONS] CONTAINER
COMMAND [ARG…]
and more …
https://docs.docker.com/engine/reference/commandline/docker/
https://docs.docker.com/engine/reference/commandline/docker/
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Diagram – Docker sharing
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• Export a container’s filesystem as a tar archive:
docker export [OPTIONS] CONTAINER
• Import the contents from a tarball to create a filesystem
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
• Load an image from a tar archive or STDIN:
docker load [OPTIONS]
• Save one or more images to a tar archive (streamed to
STDOUT by default)
docker save [OPTIONS] IMAGE [IMAGE…]
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Diagram – Build image from dockerfile
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• Build an image from a Dockerfile:
docker build [OPTIONS] PATH | URL | –
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Diagram – Interact with Registry
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• Pull an image or a repository from a registry:
docker pull [OPTIONS]
• Push an image or a repository to a registry:
docker push [OPTIONS] NAME[:TAG]
• Search the Docker Hub for images:
docker search [OPTIONS] TERM
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Docker Command Demo
https://philipzheng.gitbook.io/docker_practice/appendix_command
Cloud Computing
• Check the available docker images and running containers
• Pull an existing docker: ubuntu:18.04; run it as a container
• Execute a bash command in this container
• Install some apps
• Stop and restart the container
• Test if the apps can be kept without commit
• Commit the images
• Re-test if the apps can be kept
• Check differences
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Cloud Computing
• Container
• What is Docker
• Basic concepts in Docker
– Layer architecture
– Containers
– Registry
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
17/08/2021
CRICOS code 00025BCRICOS code 00025B
The process of taking an application and configuring it to run as a
container is called “containerizing” or “Dockerizing”.
Containers are all about apps! In particular, they’re about making apps
simple to build, ship, and run.
An sharing example:
• Use docker commands to construct an image layer by layer
• Use docker commit to make changes when necessary
• Use docker pull/push to share with others via public/private registry
Any problems that may concern the other users?
• Size of image/container
• Contents of image/container(malicious software)
A simple solution: an “audit” file that lists all contents in this image
Containerizing an app
https://blog.netapp.com/blogs/containers-vs-vms/
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
The process of containerizing an app:
1. Start with your application code.
2. Create a Dockerfile that describes your app, its
dependencies, and how to run it.
3. Feed this Dockerfile into the docker image build
4. Sit back while Docker builds your application into a
Docker image and push image to Docker Registry
5. Your team mates and you can remotely/locally run
the image as a container
Containerizing Steps
https://blog.netapp.com/blogs/containers-vs-vms/
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
• is a text file that defines the environment inside
the container
• is a collection of instructions and commands
(blueprint)
• clearly tells what are contained in the image.
• Docker can build images automatically by
reading the instructions from a Dockerfile
– Usage example: docker build
• Docker image is in form of dockerfile
• http://www.w3big.com/docker/docker-
install-nginx.html
Dockerfile
https://blog.netapp.com/blogs/containers-vs-vms/
Cloud Computing
http://www.w3big.com/docker/docker-install-nginx.html
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Launch a Nginx container with Docker CLI commands
Cloud Computing
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Launch a Nginx container with a Dockerfile
Cloud Computing
dockerfile
Index.html
17/08/2021
CRICOS code 00025BCRICOS code 00025B
Union FS in Image Build
FROM ubuntu
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com