Wednesday, 10 April 2024
Roadmap Links
roadmap
https://github.com/canopas/web-devops-roadmap/tree/main*********
https://www.youtube.com/watch?v=tbv1lTF1wFU&list=PL8VzFQ8k4U1Jp6eWgHSXHiiRWRvPyCKRj&index=2
https://github.com/canopas/web-devops-roadmap/tree/main
https://mguery.github.io/devops-notes/
https://code.visualstudio.com/docs/azure/extensions
https://code.visualstudio.com/docs/azure/deployment
https://github.com/bregman-arie/devops-exercises ----->spr**********
https://learn.microsoft.com/en-us/azure/static-web-apps/getting-started?tabs=vanilla-javascript
To Do
kubernetes
part01 - Installing the cluster. ✅
part02 - getting ready for production. ✅
part03 - How to reach my application - LoadBalance! ✅
part04 - How to reach my application - Ingress Controller ✅
part05 - Where is my data (Storage solutions) ✅
part05.1 - NFS Dynamic Provisioning ✅
part05.2 - Glusterfs
part06 - Monitoring ✅
part07 - Mr Jenkins, we need you ✅
part08 - Where is my CA Certificate
part09 - Im tired of kubectl
part10 - Lets wrap up
This script including the following:
Building the infrastructure:
(Kubernetes Cluster) EKS
(Container Registry) ECR
(Storage Bucket) S3
Deploy Ingress
Deploy Monitoring (Prometheus, Alertmanager, Grafana)
Update the kubeconfig
Build the Docker image
Login and push the Docker image to the ECR
Create Namespace for the app
Deploy the application
oad Balancers - Load Balancing Algorithms
Explain each of the following load balancing techniques
Round Robin
Weighted Round Robin
Least Connection
Weighted Least Connection
Resource Based
Fixed Weighting
Weighted Response Time
Source IP Hash
URL Hash
#
# DevOps Interview Questions
## Question 1:
### Docker vs Vagrant
```
Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation
Docker Containers are generally more lightweight than virtual machines, so starting and stopping containers is extremely fast.
Both Vagrant and Docker have a vast library of community-contributed "images" or "boxes" to choose from.
```
## Question 2:
### What is SAAS, PAAS & IAAS stand for?
```
SAAS: Software as a Service, also known as cloud application services, SaaS utilizes the internet to deliver applications, which are managed by a third-party vendor, to its users. A majority of SaaS applications run directly through your web browser, which means they do not require any downloads or installations on the client side.
PAAS: Cloud platform services, also known as Platform as a Service, PaaS delivers a framework for developers that they can build upon and use to create customized applications. All servers, storage, and networking can be managed by the enterprise or a third-party provider while the developers can maintain management of the applications.
IAAS: Cloud infrastructure services, known as Infrastructure as a Service, Cloud infrastructure services, known as Infrastructure as a Service
```
## Question 3:
### What is VPC?
```
VPC is Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.
```
## Question 4:
### What is IAC?
[Watch explaination here](https://www.youtube.com/watch?v=zF_N4flz8lw)
```
IAC is Infrastructure as Code which is managing and provisioning of infrastructure through code instead of through manual processes.
```
## Question 5:
### Cloud Regions vs Availability Zones?
```
Amazon EC2 is hosted in multiple locations world-wide. These locations are composed of Regions, Availability Zones, Local Zones, AWS Outposts, and Wavelength Zones. Each Region is a separate geographic area.
The Availability Zones are multiple, isolated locations within each Region.
```
## Question 6:
### What is EKS?
[Watch explaination here](https://www.youtube.com/watch?v=4Tkxe0VjrYw)
```
EKS is Amazon Elastic Kubernetes Service whcih is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS.
```
## Question 7:
### What is ECR?
```
ECR is Amazon Elastic Container Registry which is an AWS managed container image registry service that is secure, scalable, and reliable. Amazon ECR supports private repositories with resource-based permissions using AWS IAM.
```
## Question 8:
### Pods vs Deployments?
```
The pod is the smallest unit of Kubernetes used to house one or more containers and run applications in a cluster, while deployment is a tool that manages the performance of a pod and start it when it is down.
```
## Question 9:
### What is Cloud Formation?
```
AWS CloudFormation is a service that gives developers and businesses an easy way to create a collection of related AWS and third-party resources, and provision and manage them in an orderly and predictable fashion.
```
## Question 10:
### Horizontal Scaling vs Vertical Scaling?
[Watch explaination here](https://www.youtube.com/watch?v=YfJZBngbhM8&t=744s)
```
While horizontal scaling refers to adding additional nodes, vertical scaling describes adding more power to your current machines.
```
## Question 11:
### What Kubectl is used for?
[Watch explaination here](https://www.youtube.com/watch?v=kV4jINv3s-k)
```
Kubectl is the Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For more information including a complete list of kubectl operations.
```
## Question 12:
### Monolithic vs Microservices?
[Watch explaination here go to min 00:24](https://www.youtube.com/watch?v=YfJZBngbhM8&t=20s)
```
A monolithic application is built as a single unit, normally, monolithic applications have one large code base and lack modularity. If developers want to update or change something, they access the same code base. So, they make changes in the whole stack at once.
While a monolithic application is a single unified unit, a microservices architecture breaks it down into a collection of smaller independent units. These units carry out every application process as a separate service. So all the services have their own logic
```
## Question 13:
### What is LoadBalancer?
[Watch explaination here go to min 2:23](https://www.youtube.com/watch?v=4Tkxe0VjrYw)
```
Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers, also known as a server farm or server pool.
```
## Question 14:
### What is Elasticity?
[Watch explaination here go to min 00:34](https://www.youtube.com/watch?v=kV4jINv3s-k&t=4s)
```
The Elasticity refers to the ability of a cloud to automatically expand or compress the infrastructural resources on a sudden-up and down in the requirement so that the workload can be managed efficiently. This elasticity helps to minimize infrastructural cost.
```
## Question 15:
### What is Target groups?
```
Each target group is used to route requests to one or more registered targets. When you create each listener rule, you specify a target group and conditions. When a rule condition is met, traffic is forwarded to the corresponding target group. You can create different target groups for different types of requests. For example, create one target group for general requests and other target groups for requests to the microservices for your application.s
```
## Question 16:
### What High Availability means?
[Watch explaination here go to min 1:18](https://www.youtube.com/watch?v=kV4jINv3s-k)
```
High availability is the ability of a system to operate continuously without failing for a designated period of time the minimum number of nodes to acheive the High availability is 3 nodes
```
## Question 17:
### Master node vs Worker node?
[Watch explaination here go to min 6:19](https://www.youtube.com/watch?v=YfJZBngbhM8)
```
The master node is responsible for running several Kubernetes processes it contains (API Server, Controller manager, Scheduler and etcd)
The worker nodes are the part of the Kubernetes clusters which actually execute the containers and applications on them. They have two main components, the Kubelet Service and the Kube-proxy Service.
```
---
## Question 18: (Kubernetes)
### What is Kubernetes and how does it work?
```
Kubernetes is an open-source platform that automates the deployment, scaling, and management of containerized applications. It works by creating a cluster of worker nodes that can run containerized applications, and managing those nodes and applications through a central control plane.
```
## Question 19:
### Can you explain the difference between a pod and a deployment in Kubernetes?
```
A pod is the smallest deployable unit in Kubernetes, consisting of one or more containers that share the same network and storage resources. A deployment is a higher-level abstraction that manages a set of replica pods, ensuring that the desired number of replicas are running and that they are updated and rolled out gracefully.
```
## Question 20:
### How do you scale a deployment in Kubernetes?
```
You can scale a deployment in Kubernetes by updating its replica count using the kubectl scale command or by modifying its YAML configuration file and applying the changes using kubectl apply.
```
## Question 21:
### How do you monitor and troubleshoot a Kubernetes cluster?
```
You can monitor and troubleshoot a Kubernetes cluster using various tools and techniques, including logging and metrics collection, tracing, and debugging. Common tools for monitoring and troubleshooting Kubernetes include Prometheus, Grafana, Jaeger, and kubectl commands like kubectl logs and kubectl exec.
```
## Question 22:
### What is a service in Kubernetes and why is it needed?
```
A service in Kubernetes is an abstract way to expose an application running on a set of pods as a network service. It provides a stable IP address and DNS name for the pods, and allows other applications to access the service through a consistent endpoint.
```
## Question 23:
### How do you deploy a containerized application to Kubernetes?
```
To deploy a containerized application to Kubernetes, you need to create a Kubernetes deployment or a pod YAML configuration file that describes the application's container image, resource requirements, and other settings. You can then apply the configuration using kubectl apply or create commands.
```
## Question 24:
### What are the different types of Kubernetes volumes and when would you use each type?
```
There are several types of Kubernetes volumes, including hostPath, emptyDir, configMap, secret, persistentVolumeClaim, and more. Each type is designed to support different use cases and storage requirements, such as temporary storage, shared configuration, or persistent data storage.
```
## Question 25:
### What is a Kubernetes ConfigMap and how would you use it?
```
A ConfigMap is a Kubernetes object that provides a way to store configuration data as key-value pairs that can be consumed by containers running in a pod. You can use a ConfigMap to store environment variables, command-line arguments, and other configuration options.
```
## Question 26:
### Can you explain the concept of a Kubernetes namespace?
```
A namespace is a way to partition a Kubernetes cluster into multiple virtual clusters. It provides a way to group related objects together and to provide isolation between different parts of your application. You can use namespaces to limit resource usage, provide access control, and simplify management of your Kubernetes cluster.
```
## Question 27:
### How do you perform a rolling update of a Kubernetes deployment?
```
You can perform a rolling update of a Kubernetes deployment by updating the deployment manifest file with the new container image or configuration options and then using kubectl apply to apply the changes. Kubernetes will automatically roll out the update to the pods in the deployment, one at a time, while keeping the application available to users.
```
---
## Question 28: (Infrastructure as a Code)
### What is Infrastructure as Code (IaC), and how does it differ from traditional infrastructure management approaches?
```
Infrastructure as Code (IaC) is a practice of managing and provisioning infrastructure through code, using version control systems and automation tools. It differs from traditional infrastructure management approaches, which typically rely on manual configuration and require extensive documentation to track changes.
```
## Question 29:
### What are some benefits of using IaC for managing infrastructure, compared to traditional approaches?
```
Some benefits of using IaC for managing infrastructure include faster and more consistent provisioning, greater agility and flexibility, easier collaboration and version control, improved security and compliance, and better cost management.
```
## Question 30:
### Can you explain how tools like Terraform and Ansible can be used for IaC?
```
Terraform and Ansible are two popular tools for IaC. Terraform is a tool for defining and provisioning infrastructure resources, while Ansible is a tool for automating configuration management tasks. Both tools use declarative configuration files to define infrastructure resources and dependencies, and can automate the entire infrastructure lifecycle.
```
## Question 31:
### How do you ensure that your IaC code is secure and follows best practices?
```
To ensure that IaC code is secure and follows best practices, it is important to implement security and compliance checks as part of the deployment pipeline. This includes using tools like static code analysis, vulnerability scanners, and compliance frameworks, as well as performing regular code reviews and testing.
```
## Question 32:
### What are some common design patterns and best practices for writing IaC code?
```
Common design patterns and best practices for writing IaC code include modularizing infrastructure code, using parameterized templates, versioning infrastructure code, using version control systems, and testing code changes before deploying to production.
```
## Question 33:
### How do you test and validate your IaC code before deploying it to production?
```
IaC code can be tested and validated using a combination of automated and manual testing techniques, including unit tests, integration tests, functional tests, and user acceptance testing (UAT). It is important to test code changes in a staging environment before deploying to production.
```
## Question 34:
### What are some common challenges and limitations when using IaC, and how can they be addressed?
```
Common challenges and limitations when using IaC include managing stateful resources, dealing with complex dependencies, handling drift and resource deletion, and addressing security concerns. These challenges can be addressed by using tools and techniques like Terraform modules, Ansible playbooks, configuration drift detection, and security automation.
```
## Question 35:
### Can you explain the concept of infrastructure drift, and how IaC can help prevent it?
```
Infrastructure drift refers to the situation where the actual state of infrastructure resources differs from their intended state. IaC can help prevent infrastructure drift by automatically detecting and correcting deviations from the intended state, using tools like Terraform's "apply" command or Ansible's "check mode."
```
## Question 36:
### How do you manage secrets and sensitive data in IaC code?
```
Sensitive data and secrets can be managed in IaC code by using tools like HashiCorp Vault or AWS Secrets Manager to store and manage secrets securely, and by using environment variables or configuration files to pass secrets to the IaC tool at runtime.
```
## Question 37:
### Can you give an example of a real-world scenario where you used IaC to deploy and manage infrastructure?
```
One example of a real-world scenario where IaC can be used to deploy and manage infrastructure is the deployment of a web application on AWS. In this scenario, IaC tools like Terraform or CloudFormation can be used to define and provision infrastructure resources like EC2 instances, load balancers, and databases, while Ansible or Chef can be used to automate configuration management tasks.
```
Devops Roadmap
Web DevOps Roadmap
This repository contains a basic DevOps roadmap for all web developers. Anyone can start this training with their existing learning projects. The approximate duration to complete this roadmap is 10 days, it can vary based on experience though. # Guidelines - Before starting any practice, it's essential to conduct research and learn the necessary concepts. - Create a GitHub/GitLab repository for each Practical if one doesn't already exist. - Learn Basic DevOps Principles: - How to use Version Control effectively for your codebase as Git is Fundamental. - How to write unit tests. - Understand the core DevOps concepts like continuous integration, continuous deployment, and automation. - Basic scripts to get an overall understanding of scripting language. - Basic security practices like exposing env vars, Inbound/Outbound security rules, etc… - Note for Cloud platforms like AWS/Gcloud/Azure: - Start deploying an application manually through the AWS/Gcloud/Azure console. It will provide a solid foundational understanding of the service. - Once you've gained proficiency in this approach, transitioning to CI/CD becomes an easy process. - Some Basic Guidelines for CI/CD: - Understand the CI/CD concepts and their significance with pipeline usage. - Learn how to set up the basic CI/CD pipeline with the GitLab/GitHub-CI tool. - All lint rules should be passed from the pipeline. - Always use the latest versions of languages and project dependencies - Understand how to manage project dependencies using NPM(Node Package Manager), Yarn, Composer, or Vendors. And integrate them into the pipeline. - Learn to automate the testing into the CI/CD pipeline. - Learn how to use environment variables effectively in CI/CD pipelines including handling sensitive information like secret keys or passwords. --- # Prerequisites Learn the following before starting practice. - Linux commands for DevOps - Install dependencies - File operations - SSH commands - [Docker](https://docs.docker.com/get-started/overview/) - Concepts - swarm - services - images - containers - tags - volume - docker-compose - Create image - Create container - Run container locally - Push on the registry - Remove unused services or data - [Version control system](https://learn.microsoft.com/en-us/devops/develop/git/what-is-version-control) and [git](https://www.nobledesktop.com/learn/git/what-is-git) - [What is cloud computing?](https://aws.amazon.com/what-is-cloud-computing/) - [AWS account](https://aws.amazon.com/console/) --- # Table of contents - [Ensure code quality](https://github.com/canopas/web-devops-roadmap#ensure-code-quality) - [Practical 1 - Linting javascript code with eslint](https://github.com/canopas/web-devops-roadmap#practical-1---linting-javascript-code-with-eslint) - [Practical 2 - Linting PHP code and adding pre-commit hook](https://github.com/canopas/web-devops-roadmap#practical-2-linting-php-code-and-adding-pre-commit-hook) - [Practical 3 - Linting Golang code](https://github.com/canopas/web-devops-roadmap#practical-3---linting-golang-code) - [Automate Testing](https://github.com/canopas/web-devops-roadmap#automate-testing) - [Practical 4 - Unit test check in golang](https://github.com/canopas/web-devops-roadmap#practical-4---unit-test-check-in-golang) - [Deployment](https://github.com/canopas/web-devops-roadmap#deployment) - [Practical 5 - Build a Docker image](https://github.com/canopas/web-devops-roadmap#practical-5---build-a-docker-image) - [Practical 6 - AWS EC2 Deployment](https://github.com/canopas/web-devops-roadmap#practical-6---aws-ec2-deployment) - [Practical 7 - Configure Proxy and DNS Hosting](https://github.com/canopas/web-devops-roadmap#practical-7---configure-proxy-and-dns-hosting) - [Practical 8 - Deploy Nuxt static website on AWS S3 with Cloudfront](https://github.com/canopas/web-devops-roadmap#practical-8---deploy-nuxt-static-website-on-aws-s3-with-cloudfront) - [Practical 9 - Deploy Golang API on AWS Lambda with Route53 hosting using CloudFormation stack](https://github.com/canopas/web-devops-roadmap#practical-9---deploy-golang-api-on-aws-lambda-with-route53-hosting-using-cloudformation-stack) --- # Ensure code quality ### Practical 1 - Linting javascript code with eslint **Expected -** Configure GitLab workflow for Linting and Formatting, which should be passed without errors. - Set up the Vue.js project with typescript and create the simple component with tailwind css. - Integrate eslint and perform following rules, - Enforce naming conventions for files and folder names - Enforce naming conventions for variables and function names - Use semicolons at the end of statements - Use double quotes for strings - Enforce no trailing spaces, consistent line endings (e.g., LF or CRLF), and consistent spacing around operators - Limit the line length to a maximum of 100 characters - Limit the max 300 lines for files - Limit the max 30 lines for functions - Enforce 2 space identation - Ignore eslint check in non-javascript files - Write GitLab CI script to run lint - Create a repository on GitLab if one doesn't already exist - Configure the script to run ESlint as part of the CI/CD pipeline. - Ensure that the linting process runs on each commit. ### Practical 2 - Linting PHP code and adding pre-commit hook **Expected -** Configure GitLab workflow for Linting and Formatting, which should be passed without errors. - Set up a PHP e-commerce project and learn PHP linters. - Perform following rules, - Enforce naming conventions for files and folder names - Enforce naming conventions for variables and function names - Use semicolons at the end of statements - Use double quotes for strings - Enforce no trailing spaces, consistent line endings (e.g., LF or CRLF), and consistent spacing around operators - Limit the line length to a maximum of 100 characters - Limit the max 300 lines for files - Limit the max 30 lines for functions - Enforce 2 space identation - Setup prettier and format code with prettier - Ignore checks in non-php files - Write GitLab CI script to run lint - Create a repository on GitLab if one doesn't already exist - Configure the Pre-commit hook to run prettier before the commit - Configure the script to run Lint as part of the CI/CD pipeline. - Ensure that the linting process runs on each commit. ### Practical 3 - Linting Golang code **Expected -** Configure GitHub workflow for Linting and Formatting, which should be passed without errors. - Set up Golang API project and learn Golang linters. - Perform following rules, - Enforce naming conventions for files and folder names - Enforce naming conventions for variables and function names - Limit the line length to a maximum of 100 characters - Limit the max 300 lines for files - Limit the max 30 lines for functions - Format code - Ignore check in non-go files - Write GitHub CI script to run lint - Create a repository on GitHub if one doesn't already exist - Configure the Pre-commit hook to run prettier before the commit - Configure the script to run Lint as part of the CI/CD pipeline. - Ensure that the linting process runs on each commit. --- # Automate Testing ### Practical 4 - Unit test check in golang **Expected -** Configure GitHub workflow for running unit tests, which should be passed without errors. - Write unit tests from [Practical 22](https://github.com/canopas/web-developer-roadmap-2023#practical-22) if not already written. - Ensure the test covers all the success and error cases and passes with 85% code coverage. - Write GitHub CI script to run Unit test - Create a repository on GitHub if one doesn't already exist - Configure the database and script to run unit tests as part of the CI/CD pipeline. - Ensure that the unit test runs on each commit. --- # Deployment ## Running project using Docker on AWS EC2 ### Practical 5 - Build a Docker image **Expected -** Docker image should be available on GitLab Registry. - Set up [VueJs- admin panel](https://github.com/canopas/web-developer-roadmap-2023#practical-18) project if one doesn't already exist - Write GitLab CI script to run the docker build - Create a repository on GitLab if one doesn't already exist - Write a docker file which includes, - Install dependencies - Build and run project - Write a CI/CD script for Building a docker image and push it on the GitLab Registry. ### Practical 6 - AWS EC2 Deployment **Expected -** Admin panel successfully run on `
Dockers FAQ
dDocker commands links 50 command
https://www.fosstechnix.com/docker-basic-commands/
https://blog.devops.dev/docker-interview-questions-and-answers-for-every-solution-architect-devops-engineer-sdet-8435dd2ab147
https://github.com/collabnix/dockerlabs/blob/master/docker/docker-interview-questions.md VVVVIMP
Scenario based interview questions
Basic Interview Questions of Docker & Dockerfile:-
1. How will you run multiple Docker containers in one single host?
Answer: Docker Compose is the best way to run multiple containers as a single service by defining them in a docker-compose.yml file.
2. If you delete a running container, what happens to the data stored in that container?
Answer: When a running container is deleted, all data in its file system also goes away. However, we can use Docker Data Volumes to persist data even if the container is deleted.
3. How do you manage sensitive security data like passwords in Docker?
Answer: Docker Secrets and Docker Environment Variables can be used to manage sensitive data.
4. What is the difference between Docker Image and a Docker Container?
Answer: Docker Image is a template that contains the application, libraries, and dependencies required to run an application, whereas a Docker Container is the running instance of a Docker Image.
5. How do you handle persistent storage in Docker?
Answer: Docker Volumes and Docker Bind Mounts are used to handle persistent storage in Docker.
6. What is the process to create a Docker Container from a Dockerfile?
Answer: Docker Build command is used to create Docker images from a Dockerfile and then Docker Run command is used to create Containers from Docker images.
7. How will you scale Docker containers based on traffic to your application?
Answer: Docker Swarm or Kubernetes can be used to auto-scale Docker Containers based on traffic load.
8. When RUN and CMD instructions will be executed?
Answer: RUN instruction will be executed while building the Docker Image. CMD instruction will be executed while starting the Container.
9. What’s the different between COPY and ADD instructions?
Answer: Using COPY instruction,We can copy local files and folders from docker build context to Docker Image. These files and folders will be copied while creating a Docker Image.
ADD instruction works similar to COPY instruction but the only different is that we can download files from remote locations that’s from Internet while creating a Docker Image.
10. What’s the different between CMD and ENTRYPOINT instructions?
Answer: CMD instruction will be used to start the process or application inside the Container.
ENTRYPOINT instruction also works similar to CMD instruction. ENTRYPOINT instruction will also be executed while creating a container. CMD instruction can be overridden while creating a Container where as ENTRYPOINT instruction cannot be overridden while creating a Container.
11. When we have both CMD and ENTRYPOINT instructions in a Dockerfile?
Answer: CMD instruction will not be executed and CMD instruction will be passed as an argument for ENTRYPOINT.
--------------------------------------------------------------------------------
Last simple question…Describe a Docker container’s lifecycle.
Although there are several different ways of describing the steps in a Docker container’s lifecycle, the following is the most common:
Create container
Run container
Pause container
Unpause container
Start container
Stop container
Restart container
Kill container
Destroy container
The most critical Docker commands are:
Build. Builds a Docker image file
Commit. Creates a new image from container changes
Create. Creates a new container
Dockerd. Launches Docker daemon
Kill. Kills a container
What are Docker object labels?
Labels are the mechanism for applying metadata to Docker objects such as containers, images, local daemons, networks, volumes, and nodes.
How do you find stored Docker volumes?
Use the command: /var/lib/docker/volumes
How do you check the versions of Docker Client and Server?
This command gives you all the information you need: $ docker version
Show how you would create a container from an image.
To create a container, you pull an image from the Docker repository and run it using the following command: $ docker run -it -d
How about a command to stop the container?
Use the following command: $ sudo docker stop container name
How would you list all of the containers currently running?
U se the command: $ docker ps
List some of the more advanced Docker commands and what they do.
Some advanced commands include:
Docker info. Displays system-wide information regarding the Docker installation
Docker pull. Downloads an image
Docker stats. Provides you with container information
Docker images. Lists downloaded images
Can you lose data stored in a container?
Any data stored in a container remains there unless you delete the container.
Can a container restart on its own?
Since the default flag -reset is set to false, a container cannot restart by itself.
What are the important features of Docker?
Here are the essential features of Docker:
Easy Modeling
Version control
Placement/Affinity
Application Agility
Developer Productivity
Operational Efficiencies
What are the main drawbacks of Docker?
Some notable drawbacks of Docker are:
Doesn’t provide a storage option
Offer a poor monitoring option.
No automatic rescheduling of inactive Nodes
Complicated automatic horizontal scaling set up
What is Docker Engine?
Docker daemon or Docker engine represents the server. The docker daemon and the clients should be run on the same or remote host, which can communicate through command-line client binary and full RESTful API.
What is Docker image?
The Docker image help to create Docker containers. You can create the Docker image with the build command. Due to this, it creates a container that starts when it begins to run. Every docker images are stored in the Docker registry.
Explain Registries
There are two types of registry is
Public Registry
Private Registry
hat command should you run to see all running container in Docker?
$ docker ps
Write the command to stop the docker container
$ sudo docker stop container name
What is the command to run the image as a container?
$ sudo docker run -i -t alpine /bin/bash
What the states of Docker container?
Important states of Docker container are:
Running
Paused
Restarting
Exited
How can you monitor the docker in production environments?
Docker states and Docker Events are used to monitoring docker in the production environment.
What is Docker hub?
Docker hub is a cloud-based registry that which helps you to link to code repositories. It allows you to build, test, store your image in Docker cloud. You can also deploy the image to your host with the help of Docker hub.
What is Hypervisor?
The hypervisor allows you to create a virtual environment in which the guest virtual machines operate. It controls the guest systems and checks if the resources are allocated to the guests as necessary.
Write a Docker file to create and copy a directory and built it using python modules?
FROM pyhton:2.7-slim
WORKDIR /app
COPY . /app
docker build –tag
List out some important advanced docker commands
Command Description
docker info Information Command
docker pull Download an image
docker stats Container information
Docker images List of images downloaded
https://globalazure2024.azurewebsites.net/
https://www.fullstack.cafe/interview-questions/devops
70 Real Time Docker Interview Questions and Answers
Docker Interview Questions and Answers
1. What according to you is Docker?
A Docker can be a platform designed to ensure excellent efficiency and availability by containerizing the application and segregating them from each other for environments like production, testing or development.
Docker is a platform that allows developers to create, deploy, and run applications inside containers.
What is Container ?
A container is a lightweight, stand-alone, executable software package that includes everything needed to run a piece of software, including the code, runtime, system tools, libraries, and settings.
Containers are isolated from each other and the host system.
2. Define Docker hub or Docker Hub Registry?
Docker hub is a cloud-based registry service that lets you attach, create and send your assets to application databases, save images that have been manually sent, and connects to Docker cloud so that you can you can deploy images to your hosts.
Docker hub provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, workflow automation throughout the development pipeline.
3. What is command to pull docker image
Syntax
$ docker pull [OPTIONS] [PATH/]IMAGE_NAME[:TAG]
Example
$ docker pull ubuntu
4. How to pull docker image with specific version
$ docker pull ubuntu:18.04
5. How to pull the latest version of an image
$ docker pull ubuntu:latest
6. How to create a custom tag to docker image
$ docker tag ubuntu:latest fosstechnix/ubuntu:test
7. How to push docker image to docker hub registry using command line
$ docker push fosstechnix/ubuntu:demo
8. How to Remove all images in docker server
$ docker image rm -f
9. How to Pull your custom image from your docker account
$ docker pull fosstechnix/ubuntu:demo
10. How to pull Docker Image from Private Registry
First login to Private Registry
$ docker login myrepo.fosstechnix.com:9000
Then pull your images
Syntax:
$ docker pull [OPTIONS] ADDRESS:PORT[/PATH]/IMAGE_NAME[:TAG]
Example:
$ docker pull repo.fosstechnix.com:9000/demo-image
11. What do you mean by Docker container?
The program and all its components are included in Docker containers. The kernel is associated with several other containers and works in the host operating system as independent operations.
12. Tell me some about Hypervisor.
Hypervisor can also termed as the virtual machine monitor. This system basically divides the hosting system by delegating resources to each system equally. The possibility of turning virtualization into feasibility and practicality can be achieved only with Hypervisor.
13. Can you state the advantages of Docker over Hypervisor?
The prominent advantage of using Docker over Hypervisor is lightweight feature of the former one makes it highly feasible in terms of operations.
14. Define Docker images.
Docker images are required for establishing Docker containers. These images can be used for linking to any of the Docking environment.
15. How do you estimate the Docker server version and the client?
$ docker version
command will give the requisite information regarding the Docker client and server version.
16. Tell me something about Docker machine.
Docker machines are basically used for clustering of Docker swarms. Moreover, they are used for installation of Docker engines on the virtual hosting facilities, which can be managed using the commands from Docker machines.
17. Define Docker Swarms.
Docker swarms functions mainly by splitting a collection of Docker hosts into individual and virtual hosting spaces. As a result, the maintenance turns very easy and feasible in its operations.
18. Describe the usage of Dockerfile?
A Dockerfile is a series of specific instructions something we must send Docker to create the files. We can see the Dockerfile as a word document that has all the required commands to build a Docker Image.
OR
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
Below is workflow to create Docker Container from Dockerfile
Dockerfile –> Docker Image –> Docker Container
19. Can you please write Dockerfile to create Ubuntu Docker Image
FROM ubuntu:18.04
MAINTAINER FOSS TECHNix support@fosstechnix.com
LABEL version="1.0" \
RUN apt-get update && apt-get install -y apache2 && apt-get clean
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
COPY index.html /var/www/html
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
20. Can you please write Dockerfile to create Node Js Docker Image
FROM node:10
RUN mkdir -p /home/nodejs/app
WORKDIR /home/nodejs/app
COPY package.json .
RUN npm install
COPY . .
CMD [“node.js”, “index.js”]
EXPOSE 3000
21. What is command to build docker image from Dockerfile ?
$ docker build -t image_name .
22. What is the command to run the image as a container?
$ docker run -it ubuntu /bin/bash
Here i -> interactive, t -> terminal
23. What is command to list docker images
$ docker images
24. What is command to list specific docker image
$ docker image ls
25. How to apply port mapping a running container?
We can apply port forwarding while running a container using below command.
$ docker run -p : -d
26. What is command to login docker container
$ docker exec -it /bin/bash
27. What is command to stop a docker container
$ docker stop
28. What is command to start a docker container
$ docker start
29. What is command to remove a Docker container
$ docker rm
30. What is command to list out Running Docker containers
$ docker ps
31. What are the common instructions in Dockerfile
Below are some common instructions in Dockerfile
FROM, MAINTAINER, RUN, CMD, LABEL, EXPOSE, ENV, ADD, COPY, ENTRYPOINT, VOLUME, USER, WORKDIR, ARG, ONBUILD, STOPSIGNAL, SHELL, HEALTHCHECK
32. What is difference between ADD and COPY in Dockerfile
COPY : Copies a file or directory from your host to Docker image, It is used to simply copying files or directories into the build context.
Syntax:
COPY
Subscribe to:
Posts (Atom)
devops interview questions
Terraform* 1. Terraform workspace 2. what are Mera arguments 3. what’s difference b/w for each and dynamic block 4. provisioners in t...
-
Migrate virtual machine: The vMotion failed because the destination host did not receive data from the source host on the vMotion network....
-
ESXi host disconnects intermittently from vCenter Server (1005757) Document Id 1005757 Symptoms ESX/ESXi hosts disconnect fre...
-
Check and make sure that the process is actually stuck and not just taking a very long time. To do this, follow these steps: 1. Make sur...