0% found this document useful (0 votes)
18 views

eBook .NET 4 L4 Deploying Web Application With Docker

Uploaded by

Arkadeep Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

eBook .NET 4 L4 Deploying Web Application With Docker

Uploaded by

Arkadeep Roy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Deploying Web Application with Docker

You Already Know

Course(s):

1. Docker for the Absolute Beginner Hands-On

2. Develop and Deploy Modern Web Applications with Docker


▪ Set up and install Docker
- Docker overview
- Set up and install Docker

▪ Demonstrate Docker commands


- Basic Docker commands

▪ Demonstrate Docker Run, Docker Images, Docker Compose, and


Docker Swarm
- Docker Run
- Docker Images
- Docker Compose
- Docker Swarm
▪ Containerize your application
- Docker architecture
- Set up Docker on virtual machine

▪ Perform Docker Container Management


- Docker command line
- Docker volumes
- Docker network
A Day in the Life of a .NET Full Stack Developer

Joe has been asked to implement his knowledge on developing


ASP.NET applications and Docker containerization.

First Bank wants to use Docker to deploy all of their web applications.
Joe's manager has asked him to build a simple two-page web interface
in ASP.NET and set up a docker container to deploy the application on
it.

In this lesson, we will learn how to solve this real-world scenario to


help Joe complete his task effectively and quickly.
Learning Objectives

By the end of this lesson, you will be able to:

Demonstrate how to build an image and run it as a container

Create, run, manage, and remove images and containers

Explain Docker Hub, Docker Swarm, Docker Compose, and


Docker CE
Build an Image and Run It as a Container

Duration: 15 min.

Problem Statement:
Demonstrate the building of an image and running it as a container.
Assisted Practice: Guidelines to Build an Image and Run It as a Container

1. Setup Docker Desktop in Windows 10.

2. Build an image in Docker and run it as a container.

3. Push the code to GitHub repositories.


Various Docker Commands
Docker

Docker is a containerization platform that packages an application and all its dependencies in the form of
containers.

Features of Docker:

Ensures seamless working of the


application

Wraps the application in a complete file


system

Allows an application to be
independent of its environment
Applications of Docker

Code pipeline management


Application Rapid
isolation deployment

Simplification of
configuration Multi-tenancy
Docker Container

A container bundles an application along with all its dependencies.

Features of Docker Containers:

They share the same kernel with the host


operating system

They are not tied to any specific


infrastructure

They run as isolated processes on the


host operating system
Docker Container: Lifecycle

01 Create

02 Run

03 Pause and Unpause (optional)

04 Start

Stop

Restart

Kill
Docker Commands

Command Line Interface Description Usage

docker image build Build an image from a Dockerfile docker image build [OPTIONS] PATH |
URL | -

docker build Build an image from a Dockerfile docker build [OPTIONS] PATH | URL | -

docker run Run a command in a new docker run [OPTIONS] IMAGE


container [COMMAND] [ARG...]

docker rm Remove one or more containers docker rm [OPTIONS] CONTAINER


[CONTAINER...]

docker image rm Remove one or more images docker image rm [OPTIONS] IMAGE
[IMAGE...]
Docker Commands

Command Line Interface Description Usage

docker create Create a new container docker create [OPTIONS] IMAGE


[COMMAND] [ARG...]

docker image prune Remove unused images docker image prune [OPTIONS]

docker images List images docker images [OPTIONS]


[REPOSITORY[:TAG]]

docker ps List containers docker ps [OPTIONS]


Docker Commands

Command Line Interface Description Usage

docker kill Kill one or more running docker kill [OPTIONS] CONTAINER
containers [CONTAINER...]

docker rmi Remove one or more images docker rmi [OPTIONS] IMAGE
[IMAGE...]

docker stop Stop one or more running docker stop [OPTIONS] CONTAINER
containers [CONTAINER...]

docker rename Rename a container docker rename CONTAINER


NEW_NAME
Introduction to Docker Hub
Docker Hub

Docker Hub is a cloud-based repository used to create, test, store, and distribute container images.

Features of Docker Hub:

Docker hub helps manage, push, and pull


Repositories container images in private repositories

Teams and Docker hub allows to create workgroups to


Organizations manage access to image repositories

Docker hub provides the largest library of official


Official Images docker images.
Docker Hub

Docker hub offers high quality images from


Publisher Images external vendors

Docker hub integrates with other services and


trigger actions on successful push using
Webhooks webhooks

Docker hub allows to build container images from


GitHub and Bitbucket automatically and push
Builds them to Docker Hub
Importance and Applications
Docker Hub: Importance and Applications

Reduced application (app) download


and set up time

App accessible to the team, Docker


community

Easy creation and management of


users

Easy integration to development


pipeline through automated build and
webhooks
Tag an Image Before Pushing

Duration: 10 min.

Problem Statement:
Demonstrate how an image is tagged before pushing.
Assisted Practice: Guidelines to Demonstrate Image Tagging Before Pushing

1. Set up Docker Desktop in Windows 10.

2. Create a Docker file with the steps to deploy the image.

3. Run the Docker file and tag the image.

4. Run the container.

5. Push the code to GitHub repositories.


Push an Image to Docker Hub

Duration: 20 min.

Problem Statement:
Demonstrate how an image is pushed into Docker Hub.
Assisted Practice: Guidelines to Push an Image Into Docker Hub

1. Set up Docker Desktop in Windows 10.

2. Create a Docker file with the steps to deploy the image.

3. Run the Docker file and tag the image.

4. Run the container.

5. Push the image with a tag.

6. Push the code to GitHub repositories.


Pull an Image from Docker Hub

Duration: 20 min.

Problem Statement:
Demonstrate how an image is pulled from Docker Hub.
Assisted Practice: Guidelines to Pull an Image From Docker Hub

1. Set up Docker Desktop in Windows 10.

2. Create a Docker file with the steps to deploy the image.

3. Run the Docker file and tag the image.

4. Run the container.

5. Push the image with a tag.

6. Pull image from Docker Hub.

7. Push the code to GitHub repositories.


Introduction to Docker Swarm
Docker Swarm

Docker Swarm is the scheduling and clustering tool for Docker containers.

Containers

Swarm

Hosts
Functions of Docker Swarm

Docker Swarm is controlled through Swarm Manager.

Orchestrates and schedules containers

Swarm
Manager

Allows creation of a primary manager instance


and multiple replica instances

Swarm optimizes resources by automatically scheduling container workloads to run on


the most appropriate host and assigning containers to the underlying nodes.
Importance and Applications
Importance of Docker Swarm

Docker Swarm allows deployment of manager and worker nodes at runtime.

With the help of Docker Swarm:

A cluster of Docker nodes can be established and managed as a single virtual system.

Container iterations can be added or subtracted as per computing demands.


Applications of Docker Swarm

Scaling beyond one host

Failure tolerance and high availability

Load balancing

Automatic assignment of services


Docker Services
Docker Services

A Docker Service is created to deploy an image of an application when the Docker Engine is in Swarm
mode. A service is an image of a microservice of the the application.

A database

Examples of Docker services: An HTTP server

Any executable program to be run in a


distributed environment
Creating a Docker Service

While creating a Docker Service, the container image that is to be used and the commands to be executed
inside the running containers have to be specified.

Define the following while creating a Service:

Port where the service is available outside the Overlay network to connect other Services in
Swarm the Swarm

CPU and memory limits, and reservations Number of replicas to be run


Types of Docker Service Deployments

Docker Service can be deployed in two ways:

Replicated The number of replica tasks for the Swarm manager to


Services schedule on the available nodes are specified.

Global One task is assigned to every node by the swarm


Services manager.
Scale Your App to Run Multiple Containers

Duration: 15 min.

Problem Statement:
Demonstrate how an app is scaled to run on multiple containers.
Assisted Practice: Guidelines to Scale an App to Run on Multiple Containers

1. Set up Docker Desktop in Windows 10.

2. Set up Docker Compose.

3. Download the sample eShopOnContainers .NET application.

4. Set up a docker-compose.yml file to deploy it on multiple containers.

5. Push the code to GitHub repositories.


Deploy App to Production Using Docker

Duration: 15 min.

Problem Statement:
Demonstrate how an app is deployed to production.
Assisted Practice: Guidelines to Deploy an App to Production

1. Download a sample .NET APP.

2. Test it and deploy it locally.

3. Deploy it to a Windows Docker container which is used for production.

4. Push the code to GitHub repositories.


Setting Up Jenkins Pipeline

Duration: 15 min.

Problem Statement:
Demonstrate the setting up of Jenkins pipeline.
Assisted Practice: Guidelines to Set Up Jenkins Pipeline

1. Set up Jenkins in Windows 10.

2. Install Pipeline Plugin in Jenkins.

3. Push the code to GitHub repositories.


Introduction to Docker Compose
Docker Compose

Docker Compose is used to define and run multi-container docker applications as a single service.
Compose works on production, staging, development, testing, and continuous integration workflow
environments.

It Is a YAML file that contains details required to set up the Docker


application

It can be used to create, host separate containers, and establish


communication between containers

Runs on MacOS, Windows, and 64-bit Linux


What Is Docker Compose?

It Is a YAML file that contains details required to set up


the Docker application

It can be used to create, host separate containers, and


establish communication between containers
Getting Started with Docker Compose

Create a directory for the project and create ‘.py’ file in the project
directory

Create a Dockerfile that builds a Docker image

Define services in a Compose file

Build and run the app with Compose

Edit the Compose file to add a bind mount

Re-build and run the app with Compose


Importance And Applications
Docker Compose: Importance and Features

01 Uses multiple isolated environments on a single host

02 Preserves volume data when containers are created

Caches the container configuration and recreates only


03 when a container is changed

Supports variables and uses them to customize composition


04 for different environments
Applications of Docker Compose

Isolated development Docker Compose can be used to create and interact


environments with an isolated environment to run applications

Docker Compose can be used to deploy applications to


Single host deployments
a remote Docker engine

Automated testing Docker Compose can be used to create and destroy


environments isolated testing environments
Docker CE
Docker CE

Docker Community Engine, or Docker CE, is an open source containerization platform.

Builds production-ready container applications for Kubernetes or Swarm in the easiest


and fastest way

Works with all frameworks and programming languages

Runs on multiple platforms - Windows, Mac, Azure, AWS, CentOS, Debian, Fedora, and
Ubuntu
Features of Docker CE

Simple Setup for Docker and Kubernetes

Quick edit-test cycles with code and data volume


mounting

Easy switch from Swarm to Kubernetes

Built-in enterprise network support

Support for switching between Windows and Linux


containers
Importance And Applications
Importance of Docker CE

Runs containerized applications without lock-in

Uses free and paid add-ons from Docker cloud


to enhance CE experience
Applications of Docker CE

Docker CE can be used when price is a constraint

Docker CE can also be used to run containerized applications on any infrastructure of


choice
Docker CE

Duration: 20 min.

Problem Statement:
Demonstrate the functionalities of Docker CE.
Assisted Practice: Guidelines to Demonstrate the Functionalities of Docker CE

1. Set up Docker Desktop in Windows 10.


2. Push the code to GitHub repositories.
Key Takeaways

Container images are created, tested, stored, and


distributed in Docker Hub.

Manager and worker nodes can be deployed at runtime


using Docker Swarm.

Docker Service is used to deploy an image of the application


when the Docker Engine is in Swarm mode.

Docker Compose is used to define and run multi-container


Docker applications as a single service.

Docker CE is the easiest and the fastest way to build


production-ready Kubernetes/Swarm containers.
Deploy a Prototype Webapp of a Bank Login Page Using Docker

Duration: 30 min.
Problem Statement:

First Bank is planning to use Docker to deploy all their web applications.
Build an ASP.NET website comprising of two pages and set up a docker
container to deploy the application on it.

Perform the following:

● Create an ASP.NET Core web application containing two cshtml pages:


○ Login page for a customer.
○ Dashboard page which will show a few buttons for account-related
activities and a logout button which will send him back to the login
page.
● Set up Docker on the computer.
● Create a Windows image containing IIS and deploy this web
application.
Before the Next Class

Course:
1. Learning ELK Stack 6.0
2. Microsoft Azure Fundamental Training

You should be able to:


▪ Explain what is Elastic Stack
▪ Get started with ElasticSearch
▪ Analyze log data
▪ Build data pipeline with Logstash
▪ Explain what is cloud computing
▪ Explain core Azure services

You might also like