L08-Basics of Containerization

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Advanced Certificate Program In

Software Architectures
FOUNDATION MODULE 3: VIRTUALIZATION

L08 – Basics of
Containerization

Confidential Document
talentsprint.com
Topic

1. Container
2. Containers and Images Foundation
3. Hypervisor vs Container
4. Container Building Tools
5. Introduction to Docker
6. Docker Architecture
7. Container Lifecycle
8. First Docker Run
9. Docker Build for Micronaut application
○ Different steps
10. Docker Volume & Network
11. Container Orchestration

© Copyright, TalentSprint
12. Commands Cheat sheet

2
Container

Definition:

● Portable Runtime Entity


● Executable/deployable Unit
● Environment and application clubbed together
● Isolated process using cgroups & namespace

Benefits:
● Technology details of the container is hidden
● Polyglot application

© Copyright, TalentSprint
● Isolation
OCI https://opencontainers.org/

3
Container & Image Foundation
Image Read Only Layers
Image
Image is a prototype
Definition of required environment
● Portable
● Layered
● Architecture- Layers of file system
● Divided into chunks
Container
Container

● Running instance of docker Image

© Copyright, TalentSprint
● Each container has a writable layer
● Image Layer is common and shared
across
4
Hypervisor vs Container

© Copyright, TalentSprint
Container Building Tools

● Docker
● Kaniko: Backed by google; released in 2018
● Buildah: Backed by RedHat; released in 2018

© Copyright, TalentSprint
6
Docker

What is a Docker?
Platform
Create, Run, Manage & Share Containers

© Copyright, TalentSprint
7
Docker Architecture

© Copyright, TalentSprint
Container Lifecycle

© Copyright, TalentSprint
First Docker Run

● Run an existing docker image from dockerhub


● Different commands

© Copyright, TalentSprint
10
Docker From a Micronaut Application

● Dockerfile <Example with


alpine & apacheBench>
● FROM <base image> //
Multiple FROM
● MAINTAINER
● RUN
● COPY/ADD
● WORKDIR
● EXPOSE
● VOLUME
● CMD/ENTRYPOINT
● #comments

© Copyright, TalentSprint
11
Docker Volume
Creating storage while running a container with –v/ --
mount option:

• docker run <image Id> -v <host machine


_location>:<container_location>:options(RW/RO)

• docker run <image id> --mount type=bind,


source=<>,target=<>,option(RW/RO)

• docker run <image id> --mount


type=tmpfs,destination=<location>

Create Volume Before attaching to container:

© Copyright, TalentSprint
• docker create volume –name <name>

12
Docker Network

Requirements of network
Container Network Module Design (CNM)
Types of Networks
https://www.docker.com/blog/understanding-
docker-networking-drivers-use-cases/

Same Host : Drivers -> bridge/host


Multi Host docker Swarm mode : Drivers ->
overlay
Multi host & External Services : Drivers ->
MACVLAN/ IPVLAN

© Copyright, TalentSprint
13
Container Orchestrations

Container orchestration automates the deployment, management, scaling, and


networking of containers

● Provisioning and deployment


● Configuration and scheduling
● Resource allocation
● Container availability
● Scaling or removing containers based on balancing workloads across your
infrastructure
● Load balancing and traffic routing
● Monitoring container health
● Configuring applications based on the container in which they will run

© Copyright, TalentSprint
● Keeping interactions between containers secure

14
Container Orchestrations Tools

• Kubernetes K8S
• Red Hat OpenShift
• Apache Mesos
• GKE

© Copyright, TalentSprint
15
Command Cheat Sheet

● Command images:
● docker container ls : to get all list of running containers
● docker images : to list out all images available
● docker container ls –all/ -a : to list all containers
● docker images –digest
● docker ps: alternative of docker container ls
● docker images --help
● docker ps –all – filter “exited=0” : to list stopped
● Command image: containers
● docker image ls ● docker stop <Container Name>: to stop running
● docker pull name[:tag] container
● docker inspect <image> : to get JSON details ● docker rm <Container Name> : to delete the container
● docker image push : push built image to repo ● docker inspect <Container Name>
● docker image build ● docker logs <Container Name>
● docker image history <image name> : to get history ● docker ports <Container Name>
about the image ● docker diff <Container Name>
● docker rmi <image name/ hexcode> : to remove an ● docker commit <containerId> <image name> // running

© Copyright, TalentSprint
image container to a image

16
Thank You

talentsprint.com

You might also like