AZ-800 Part 3
Manage virtual machines and containers (15-20%)
What Are Containers in Servers?
Containers are a lightweight, portable way to run and manage applications. They allow you
to package an application and its dependencies together into a single image that can run
consistently across different environments, such as development, testing, and production.
Containers are particularly useful in server environments for improving resource efficiency,
scalability, and ease of deployment.
Key Concepts of Containers
1. Isolation:
○ Containers provide a way to isolate applications and their dependencies from
the underlying host system and from each other. This isolation is achieved
using features of the Linux kernel, such as namespaces and cgroups.
2. Portability:
○ Containers encapsulate an application and its dependencies into a single
package. This package can be run on any system that has the container
runtime installed, ensuring that the application behaves consistently across
different environments.
3. Lightweight:
○ Containers are more lightweight than virtual machines (VMs) because they
share the host system's kernel and do not require a full operating system.
This results in faster start-up times and lower resource usage.
4. Consistency:
○ By packaging an application and its dependencies together, containers
eliminate the "works on my machine" problem, ensuring that the application
runs the same way regardless of where it is deployed.
Containers vs. Virtual Machines
Feature Containers Virtual Machines
Isolation Process-level isolation using Full hardware emulation and isolation.
namespaces and cgroups.
Resource Shares the host OS kernel, Requires a full OS for each VM, higher
Efficiency uses fewer resources. resource usage.
,Start-Up Time Typically milliseconds to Typically minutes.
seconds.
Portability High portability due to Moderate portability, but dependent on
encapsulated dependencies. the hypervisor.
Overhead Lower overhead as containers Higher overhead due to full OS per
are more lightweight. VM.
Use Case Microservices, scalable web Monolithic apps, legacy systems,
apps, CI/CD pipelines. environments requiring strong isolation.
Examples of Container Technologies
1. Docker:
○ The most popular containerization platform that provides tools to create,
deploy, and manage containers. Docker images are used to package
applications and their dependencies, and Docker Engine is used to run these
containers.
2. Kubernetes:
○ An open-source container orchestration platform designed to automate the
deployment, scaling, and management of containerized applications.
Kubernetes clusters can manage large numbers of containers and services.
3. Azure Kubernetes Service (AKS):
○ A managed Kubernetes service provided by Microsoft Azure, which simplifies
the deployment and management of Kubernetes clusters in the cloud.
4. Windows Containers:
○ Containers specifically designed to run on Windows Server, allowing the use
of container technology for applications that require a Windows environment.
Benefits of Using Containers in Servers
1. Efficiency:
○ Containers use system resources more efficiently than VMs, allowing for
higher density of applications per server.
2. Scalability:
○ Containers can be easily scaled up or down to handle varying loads,
providing better performance and resource utilization.
3. Consistency:
○ Containers ensure that applications run consistently across different
environments by packaging the application and its dependencies together.
4. Agility:
, ○ Containers enable faster deployment and iteration of applications, which is
ideal for continuous integration and continuous deployment (CI/CD) pipelines.
5. Flexibility:
○ Containers support microservices architecture, where applications are broken
down into smaller, independent services that can be developed, deployed,
and scaled independently.
Example Scenario: Using Containers in a Server Environment
Scenario: Deploying a Web Application
1. Develop the Application:
○ Develop a web application using a framework like Node.js or .NET Core.
2. Create a Dockerfile:
Write a Dockerfile that describes the environment and dependencies needed to run the
application. For example:
Dockerfile
Copy code
FROM node:14
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]
○
3. Build the Docker Image:
Use the Docker CLI to build the image:
sh
Copy code
docker build -t my-web-app .
○
4. Run the Container Locally:
Test the container locally to ensure it works as expected:
sh
Copy code
docker run -p 3000:3000 my-web-app
○
5. Deploy to a Server:
Manage virtual machines and containers (15-20%)
What Are Containers in Servers?
Containers are a lightweight, portable way to run and manage applications. They allow you
to package an application and its dependencies together into a single image that can run
consistently across different environments, such as development, testing, and production.
Containers are particularly useful in server environments for improving resource efficiency,
scalability, and ease of deployment.
Key Concepts of Containers
1. Isolation:
○ Containers provide a way to isolate applications and their dependencies from
the underlying host system and from each other. This isolation is achieved
using features of the Linux kernel, such as namespaces and cgroups.
2. Portability:
○ Containers encapsulate an application and its dependencies into a single
package. This package can be run on any system that has the container
runtime installed, ensuring that the application behaves consistently across
different environments.
3. Lightweight:
○ Containers are more lightweight than virtual machines (VMs) because they
share the host system's kernel and do not require a full operating system.
This results in faster start-up times and lower resource usage.
4. Consistency:
○ By packaging an application and its dependencies together, containers
eliminate the "works on my machine" problem, ensuring that the application
runs the same way regardless of where it is deployed.
Containers vs. Virtual Machines
Feature Containers Virtual Machines
Isolation Process-level isolation using Full hardware emulation and isolation.
namespaces and cgroups.
Resource Shares the host OS kernel, Requires a full OS for each VM, higher
Efficiency uses fewer resources. resource usage.
,Start-Up Time Typically milliseconds to Typically minutes.
seconds.
Portability High portability due to Moderate portability, but dependent on
encapsulated dependencies. the hypervisor.
Overhead Lower overhead as containers Higher overhead due to full OS per
are more lightweight. VM.
Use Case Microservices, scalable web Monolithic apps, legacy systems,
apps, CI/CD pipelines. environments requiring strong isolation.
Examples of Container Technologies
1. Docker:
○ The most popular containerization platform that provides tools to create,
deploy, and manage containers. Docker images are used to package
applications and their dependencies, and Docker Engine is used to run these
containers.
2. Kubernetes:
○ An open-source container orchestration platform designed to automate the
deployment, scaling, and management of containerized applications.
Kubernetes clusters can manage large numbers of containers and services.
3. Azure Kubernetes Service (AKS):
○ A managed Kubernetes service provided by Microsoft Azure, which simplifies
the deployment and management of Kubernetes clusters in the cloud.
4. Windows Containers:
○ Containers specifically designed to run on Windows Server, allowing the use
of container technology for applications that require a Windows environment.
Benefits of Using Containers in Servers
1. Efficiency:
○ Containers use system resources more efficiently than VMs, allowing for
higher density of applications per server.
2. Scalability:
○ Containers can be easily scaled up or down to handle varying loads,
providing better performance and resource utilization.
3. Consistency:
○ Containers ensure that applications run consistently across different
environments by packaging the application and its dependencies together.
4. Agility:
, ○ Containers enable faster deployment and iteration of applications, which is
ideal for continuous integration and continuous deployment (CI/CD) pipelines.
5. Flexibility:
○ Containers support microservices architecture, where applications are broken
down into smaller, independent services that can be developed, deployed,
and scaled independently.
Example Scenario: Using Containers in a Server Environment
Scenario: Deploying a Web Application
1. Develop the Application:
○ Develop a web application using a framework like Node.js or .NET Core.
2. Create a Dockerfile:
Write a Dockerfile that describes the environment and dependencies needed to run the
application. For example:
Dockerfile
Copy code
FROM node:14
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]
○
3. Build the Docker Image:
Use the Docker CLI to build the image:
sh
Copy code
docker build -t my-web-app .
○
4. Run the Container Locally:
Test the container locally to ensure it works as expected:
sh
Copy code
docker run -p 3000:3000 my-web-app
○
5. Deploy to a Server: