0% found this document useful (0 votes)
10 views46 pages

(CC - 23) Lab 4

Uploaded by

salemaymen814
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views46 pages

(CC - 23) Lab 4

Uploaded by

salemaymen814
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 46

Cloud Computing

Lab 4
Agenda

• What Docker?
• Why Docker?
• Virtual machines VS Containers
• Architecture of Docker
• Basic Docker commands
• Demo
• Hands-on
Quick Recap

Operating System:
• An operating system (OS) is system software that manages
computer hardware, software resources, and provides
common services for computer programs.
Quick Recap

Kernel:
• Portion of the OS code that is always resident in
memory.
• Facilitates interactions between hardware and
software components.
Problem

• You have three different Python-based applications that you


plan to host on a single server
▪ (which could either be a physical or a virtual machine).
• Each one makes use of a different version of Python,
▪ As well as the associated libraries and dependencies, differ from one
application to another.
• We cannot have different versions of Python installed on the
same machine, which prevents us from hosting all three
applications on the same computer.
Solution 1: without using VMs or Docker
Can we do
better?

App 1 App 2 App 3

Bins/Libs Bins/Libs Bins/Libs

Host OS Host OS Host OS

Physical Machine 1 Physical Machine 2 Physical Machine 3


for Version X for Version Y for Version Z
Solution 2: using Virtual Machines
App 1 App 2 App 3

Bins/Libs Bins/Libs Bins/Libs

Guest OS Guest OS Guest OS

Version X Version Y Version Z Version X Version Y Version Z

Can we do Detailed
better?
i.e.
Hypervisor - VirtualBox
- VMWare
- Windows Hyper-v

Single Physical Machine


(powerful enough to host and run three VMs on it)
Solution 2: using Virtual Machines
App 1 App 2 App 3

Bins/Libs Bins/Libs Bins/Libs

Guest OS Guest OS Guest OS

Version X Version Y Version Z Version X Version Y Version Z


Host OS
Really!
Detailed
How ?

Hypervisor

Single Physical Machine


(powerful enough to host and run three VMs on it)
Solution 2: using Virtual Machines
App 1 App 2 App 3

Bins/Libs Bins/Libs Bins/Libs

Version X Version Y Version Z Version X Version Y Version Z


Host OS
Host OS

Detailed

Container i.e.
Runtime - Docker
- runC
- Containerd
- Windows
Containers

Single Physical Machine


(powerful enough to host and run three VMs on it)
What is Containers?

• Standardized packaging for software


and dependencies
• Isolate apps from each other
• Share the same OS kernel
• Works for all major Linux distributions
• Created by using an image.
What is Docker?

• A software platform that simplifies the


process of building, running, managing and
distributing applications.
• It is virtualizing the operating system of the
host on which it is installed and running.
• Developed using the GO programming
language.
What is Docker?
• Eliminate “works on my machine”
problems when collaborating on
code with co-workers.

• Run and manage apps side-by-side


in isolated containers to get better
compute density. OPERATOR
Solution 3: using Docker
Version X Version Y Version Z Version X Version Y Version Z
Container

App 1 App 2 App 3

Bins/Libs Bins/Libs Bins/Libs

Detailed

Docker
Engine

Host OS

Docker Host Docker Host


Comparison Between The 3 Solutions
Components of Docker

Docker Engine:
• One of the core components of Docker.
• Responsible for the overall functioning of the Docker platform.
• A client-server based application.
• Consists of 3 main components:
▪ Server Client Server
▪ REST API
▪ Client REST API

CLI Docker Engine


Components of Docker Engine
• The Server runs a daemon known
as dockerd (Docker Daemon)
– Responsible for creating and managing
Docker Images, Containers, Networks
and Volumes on the Docker platform.
• The REST API specifies how the
applications can interact with the
Server and instruct it.
• The Client allows users to interact
with Docker using the commands.
Docker Architecture

Process
Container

Share
Operating System OS
Kernel
Docker Architecture

Windows + Linux Linux Linux VM


Docker for Windows Architecture with WSL
Advantages of using Docker

• Supports hosting multiple applications with different


requirements together on the same host.
▪ They must have the same OS requirements.
• Storage Optimized
• Robustness
• Reduces costs
Disadvantages of using Docker

• Applications with different operating system requirements


cannot be hosted together on the same Docker Host.
Docker Command

Docker Command Line Structure

docker <command> [option(s)]

Examples:
$ docker version
$ docker info
$ docker run
Docker Command

docker version

• Check versions of CLI


and server
• Verify docker is
working.
▪ CLI can talk to engine
Docker Command

docker version

• Check versions of CLI


and server
• Verify docker is
working.
▪ CLI can talk to engine
Docker Command

docker info

Shows most
configuration values of
engine.
Docker Management Command

• In 2017, Docker realized that many


command are shown when you type
docker.
• They created management
commands,
▪ An easier way to organize all these
commands.
Docker Management Command

• Management Commands formant:


docker <command> <sub-command> [option(s)]

Examples:
$ docker run  docker container run
$ docker build  docker image build
$ docker ps  docker container ls
Docker Terminology

• Docker Image Docker Image

▪A template (stored in registry) that contains


 Application
 A cut-down OS
 Runtime environment (e.g., Node, Python, Java)
 Third-party libraries
 Environment variables
 All the dependencies required to run that application on Docker.
Docker Terminology

• Docker Container
▪An instance of the docker image running as a
process.
▪You can have many containers running off the
same image.

Docker Container
Docker Terminology

• Docker Hub
▪Docker’s default image registry.
▪The official online repository that contains Docker Images
that are available to use.
▪Allows you to store and distribute your custom images
publicly or privately, as required.
Docker Components Workflow
Docker Management Command
docker container run --publish 80:80 nginx

1. Downloaded image 'nginx' from Docker Hub.


2. Started a new container from that image (with a
randomly generated name which required to be
unique).
3. Opened port 80 on the host IP.
4. Routes that traffic to the container IP, port 80.
Docker Management Command
Docker Management Command

docker image pull <image-name>


Will only download image <image-name> from
Docker Hub if that image doesn’t exist locally.
Docker Management Command

docker container start <container-name-or-id>


Start one or more stopped containers.

docker container stop <container-name-or-id>


Stop one or more running containers.
Docker Management Command

docker container ls
List containers.

docker container rm
Remove one or more containers.
Docker Management Command

docker container top


Display the running processes of a container.
docker container inspect
Display detailed information on one or more containers
configurations.
docker container inspect
Display a live stream of container(s) resource usage
statistics
Demo: Create and Use Containers

DEMO
Demo: Create and Use Containers

$ docker container run --publish 80:80 –detach nginx  “--detach” or “-d”


will tell docker to run the container in the background.
$ docker container run --publish 8080:80 –detach nginx  port format
“Host:Container”.
$ docker container ls  List running containers.
$ docker container ls -a  List all containers.
$ docker container stop/start  Stop/Start containers.
$ docker container rm  Remove containers.
$ docker container rm -f  Force remove running containers.

$ docker container run mongo


$ docker container top mongo  displays processes running inside container
$ ps –e or aux | grep mongo
$ docker container stop mongo
$ ps –e or aux | grep mongo
Hands-On
Hands-On: Manage Multiple Containers
• Run a nginx, a mysql, and a httpd (apache) server
• Run all of them --detach (or -d), name them with --name
• nginx should listen on 80:80, httpd on 8080:80, mysql on
3306:3306
• When running mysql, use the --env option (or -e) to pass in
MYSQL_RANDOM_ROOT_PASSWORD=yes
• Use docker container logs on mysql to find the random
password it created on startup
• Clean it all up with docker container stop and docker
container rm (both can accept multiple names or ID's)
• Use docker container ls to ensure everything is correct
before
Hands-On: Manage Multiple Containers Solution
$ docker container run -d -p 3306:3306 --name db -e
MYSQL_RANDOM_ROOT_PASSWORD=yes mysql
$ docker container log db | grep -i “root password”

$ docker container run -d --name webserver -p 8080:80 httpd

$ docker container run --publish 80:80 –d --name proxy nginx

$ docker container ls # to check containers are up and running

# navigate to localhost:8080 for httpd & localhost:80 for nginx

$ docker container stop webserver proxy db


$ docker container rm webserver proxy db
Helpful Reference

• Play with Docker


Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy