Showing posts with label 20. Show all posts
Showing posts with label 20. Show all posts

December 26, 2019

Top 20 Docker Interview Questions & Answers



Ques: 1. What do you understand by Docker?
 
Ans: Docker is an open-source lightweight containerization technology. It has gained widespread popularity in the cloud and application packaging world. It allows you to automate the deployment of applications in lightweight and portable containers.


Ques: 2. What is Docker image?

Ans: 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.


Ques: 3. What is Virtualization?

Ans: Virtualization is a method of logically dividing mainframes to allow multiple applications to run simultaneously.

However, this scenario changed when companies and open source communities were able to offer a method of handling privileged instructions. It allows multiple OS to run simultaneously on a single x86 based system.


Ques: 4. Can you explain the process of scaling your Docker containers?
 
Ans: The Docker containers can be scaled to any level starting from a few hundred to even thousands or millions of containers. The only condition for this is that the containers need the memory and the OS at all times, and there should not be a constraint when the Docker is getting scaled.


Ques: 5. What is CNM?

Ans: CNM stands for Container Networking Model. It is a standard or specification from Docker, Inc. that forms the basis of container networking in a Docker environment. This docker's approach provides container networking with support for multiple network drivers.


Ques: 6. Can you explain the Docker Trusted Registry?

Ans: Docker Trusted Registry is the enterprise-grade image storage toll for Docker. You should install it after your firewall so that you can securely manage the Docker images you use in your applications.


Ques: 7. How do I run multiple copies of Compose file on the same host?

Ans: Compose uses the project name which allows you to create unique identifiers for all of a project's containers and other resources. To run multiple copies of a project, set a custom project name using the -a command-line option or using COMPOSE_PROJECT_NAME environment variable.


Ques: 8. What is Hypervisor?

Ans: A hypervisor is a software that makes virtualization possible. It is also called Virtual Machine Monitor. It divides the host system and allocates the resources to each divided virtual environment. You can basically have multiple OS on a single host system. There are two types of Hypervisors:

Type 1: It’s also called Native Hypervisor or Bare metal Hypervisor. It runs directly on the underlying host system. It has direct access to your host’s system hardware and hence does not require a base server operating system.

Type 2: This kind of hypervisor makes use of the underlying host operating system. It’s also called Hosted Hypervisor.


Ques: 9. What is containerization?

Ans:In the software development process, code developed on one machine might not work perfectly fine on any other machine because of the dependencies. This problem was solved by the containerization concept. 

So basically, an application that is being developed and deployed is bundled and wrapped together with all its configuration files and dependencies. This bundle is called a container. Now when you wish to run the application on another system, the container is deployed which will give a bug-free environment as all the dependencies and libraries are wrapped together. Most famous containerization environments are Docker and Kubernetes.


Ques: 10. What is the difference between virtualization and containerization?

Ans: Once you’ve explained containerization and virtualization, the next expected question would be differences. The question could either be differences between virtualization and containerization or differences between virtual machines and containers. Either way, this is how you respond.

Containers provide an isolated environment for running the application. The entire user space is explicitly dedicated to the application. Any changes made inside the container is never reflected on the host or even other containers running on the same host. Containers are an abstraction of the application layer. Each container is a different application.

Whereas in Virtualization, hypervisors provide an entire virtual machine to the guest(including Kernal). Virtual machines are an abstraction of the hardware layer. Each VM is a physical machine.


Ques: 11. Explain Docker Architecture?

Ans: Docker Architecture consists of a Docker Engine which is a client-server application with three major components:

  1. A server which is a type of long-running program called a daemon process (the docker command). 
  2. A REST API which specifies interfaces that programs can use to talk to the daemon and instruct it what to do. 
  3. A command line interface (CLI) client (the docker command). 
  4. The CLI uses the Docker REST API to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI.

  
Ques: 12. What is a Dockerfile?

Ans: Let’s start by giving a small explanation of Dockerfile and proceed by giving examples and commands to support your arguments.

Docker can build images automatically by reading the instructions from a file called Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build, users can create an automated build that executes several command-line instructions in succession.


Ques: 13. What is the life cycle of a Docker Container?
Ans: This is one of the most popular questions asked in Docker interviews. Docker containers have the following life cycle:

  • Create a container 
  • Run the container 
  • Pause the container(optional) 
  • Un-pause the container(optional) 
  • Start the container 
  • Stop the container 
  • Restart the container 
  • Kill the container 
  • Destroy the container


Ques: 14. How do you scale your Docker containers?
Ans: Docker containers can be scaled to any level, starting from a few hundreds to even thousands or millions of containers. The only condition is that the containers need the memory and the OS all the time, and there should not be a constraint on these when the Docker is getting scaled.


Ques: 15. What is the difference between the COPY and ADD commands in a Dockerfile?

Ans: Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. 

That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.


Ques: 16. What are the most common instructions in Dockerfile?

Ans: Some of the common instructions in Dockerfile are as follows:

  • FROM: We use FROM to set the base image for subsequent instructions. In every valid Dockerfile, FROM is the first instruction. 
  • LABEL: We use LABEL to organize our images as per project, module, licensing etc. We can also use LABEL to help in automation. In LABEL we specify a key value pair that can be later used for programmatically handling the Dockerfile. 
  • RUN: We use RUN command to execute any instructions in a new layer on top of the current image. With each RUN command we add something on top of the image and use it in subsequent steps in Dockerfile. 
  • CMD: We use CMD command to provide default values of an executing container. In a Dockerfile, if we include multiple CMD commands, then only the last instruction is used.


Ques: 17. Can you explain the basic Docker usage workflow?

Ans:
  1. Everything starts with the Dockerfile. The Dockerfile is the source code of the Image. 
  2. Once the Dockerfile is created, you build it to create the image of the container. The image is just the "compiled version" of the "source code" which is the Dockerfile. 
  3. Once you have the image of the container, you should redistribute it using the registry. The registry is like a git repository -- you can push and pull images. 
  4. Next, you can use the image to run containers. A running container is very similar, in many aspects, to a virtual machine (but without the hypervisor).

 
Ques: 18. What are some similarities between Virtual Machine & Docker ?

Ans: Docker is not just like a Virtual Machine. It uses the host kernel & can’t boot a different operating system. So 5 similarities between Docker & VIrtual Machine can be:

Virtual Machine
Docker
Process in on VM cant see processes in other VMs
Process in one container cant see processes in other container
Each VM has its own root filesystem

Each container has its own root file system (Not Kernal)

Each VM gets its own virtual network adapter

Docker can get virtual network adapter. It can have  separate IP and ports

VM is a running instance of physical files(.VMS and .VMDK)

Docker containers are running instances of Docker Image

Host OS can be difference from guest OS

Host OS can be different from Container OS


Ques: 19. What are some of the differences between Docker container & Virtual Machine?

Ans: The differences between docker container and virtual machines are following:

Virtual Machine

Docker
Each Virtual Machine runs its own OS.

All containers share the same kernel of the host.
Boot up time is in minutes.
Containers instantiate in seconds.
Virtual Machines snapshots are used sparingly.

Images are build incrementally on top of another like layers. Lots operating system images/snapshots.
Not effective diffs.Not version controlled.

Images can be diffed and can be version controlled.Dockerhub is like GITHUB.

Cannot run more than couple of VMs on an average laptop.
Can run many Docker containers in a laptop.

Only one VM can be started from one set of VMx and VMDK files.

Multiple Docker containers can be started from one Docker image.



Ques: 20. Can I use JSON instead of YAML for my Docker Compose file? 

Ans: Yes. YAML is a superset of json so any JSON file should be valid YAML. To use a JSON file with Compose, specify the filename to use, for example:
 
 docker-compose -f docker-compose.json up


You can use json instead of YAML for your compose file, to use json file with compose, specify the filename to use.






December 23, 2019

Top 20 BlockChain interview Questions & Answers


Ques: 1. What are the differences between a traditional database and Blockchain database?

Ans: The difference between a traditional database and blockchain database is as follows:

1. Storage of Records: In a traditional system the records are centralized whereas in Blockchain the records are decentralized.

2. Operations Done: In a Blockchain system, you can only perform insert operations whereas in the traditional system you can read, edit, create and update the transactions.

3. Validations of transactions: You can validate any number of transactions on the network in a Blockchain whereas in the traditional database only specific nodes are allowed to validate the transactions.


Ques: 2. What are Ethereum Smart Contracts and in which language is Ethereum written?

Ans: A Smart Contract is a set of program that gets automatically executed on meeting the certain requirements of Blockchain. Ethereum is generally written in Solidity programming language.


Ques: 3. What are the types of record that can be kept in Blockchain?

Ans: In Blockchain, you can keep any number of records. Few of the records that can be kept in the blockchain ledger are:

1. Medical Transactions and history

2. The identity of numerous persons

3. Several numbers of events that take place in an organization and organizational records

4. Management records of companies that can be accessed from anywhere in the world with proper secure transactions

5. Documents that are to be kept at high-level security


Ques: 4. What are the benefits of Blockchain in business?

Ans: European Banks have already launched their projects to use this technology. The international payments system VISA has also joined them. Blockchain gives several advantages to the financial sector some of which are listed below:
  • Money Transfer will become faster and cheaper payments are possible and significantly reduce their costs. 
  • With the help of the Smart Contracts are computer programs which facilitate to verify and negotiation of the agreement. 
  • In stock exchange Blockchain can remove brokers as intermediaries and decentralize the stock exchange system.

Ques: 5. What are the basic components of the Blockchain Ecosystem?

Ans: There are four basic components of Blockchain ecosystem as explained here:
  • Shared Ledger:  It is a distributed data structure shared among peers managed inside Node application. 
  • Node Application: Each of the nodes is installed and run on a computer to become a part of the blockchain network. 
  • Virtual Machine: Here the implementation of instruction takes place and every participant runs that VM. 
  • Consensus Algorithm: It is implemented as a part of node application which provides the rules for validation of transactions.

Ques: 6. How many cryptographic algorithms are used in Blockchain?

Ans: Here are some of the widely used cryptographic algorithms:
  • Triple DES: DES stands for digital encryption system which uses 3 different keys of 56 bits. 
  • RSA: It is used in several areas in the digital certificate which is a public key encryption algorithm to encrypt the information transferred on the internet. 
  • Blowfish: It is highly effective and works with great speed which encrypts the cipher messages individually. 
  • Twofish: It is similar to blowfish with keys of length 256 bits. 
  • AES: Of all algorithms, AES is the strongest encryption algorithm to breach out as it uses 192 and 256 length bit keys for heavy encryption.

Ques: 7. Can you explain pragma and provide its syntax?

Ans: Pragma is a version of Solidity that will be used by the code that is written in the solidity. For using solidity as a compiler and writing smart contracts the version should be higher than 0.4.0. Every Smart contract starts with pragma only.

Syntax: version pragma ^0.4.00.


Ques: 8. What do you mean by Merkle trees and explain its importance in Blockchain?

Ans: Also called as the hash tree, Merkle tree is the fundamental part of a Blockchain. merkle tree uses cryptographic blocks which are used to securely transact large chunks of data. Both Ethereum and Bitcoin use Merkle trees.


Ques: 9. What do you understand by 51% attack?

Ans: The blockchain is a chain of blocks that stores all transactional data in a period. Once the block enters the system it cannot be altered, and the fraudulent data would be automatically rejected by network users. However, if 51% of the miners are controlled then a group of attackers can interfere with the process of recording of new blocks. 
They can block other users transactions and reverse it also. It is also known as double spending. A network that would allow double spending could suffer a loss of confidence. Then this kind of attack is called a 51% attack.


Ques: 10. What is a block in blockchain technology?

Ans: Blocks are the storage unit of the blockchain. They are fundamental to the network, and the transactions data is stored within them. They be books with each page equivalent to a transaction. Blocks are immutable. This means if a data is recorded, it cannot be changed or deleted. Also, blocks are organized linearly in a blockchain.
A block is mined by a miner which acts to verify the transaction. This means that until a transaction is not mined, it will not be shown on the blockchain and the transaction will be deemed incomplete.


Ques: 11. What is the role of encryption in blockchain?

Ans: Encryption is an age-old technique to protect data from third parties or leak. It is the basics of data security in the modern world. Blockchain also utilizes encryption to good effect. The data before it is sent off to the receiver is encrypted. The received will only be able to unlock it as it is only meant for him. Once the receiver receives it, it is unencrypted and can be used as liked.
Blockchain also uses encryption in other ways. Also, modern blockchain solution tends to improve encryption and provide complete privacy-based experience for users.


Ques: 12. What is the difference between the standard ledger and a blockchain ledger?

Ans: The biggest difference between these two types of ledger is the decentralization that they have to offer. Blockchain ledger is decentralized which means that it offers unique capabilities such as trust, immutability, transparency, and security. Standard ledger does carry these features but is limited to certain extent.
As humans create, modify and monitor the standard ledger, there is always a chance of an error creeping in or worse a security breach. Blockchain ledger solves all the problems that standard ledger has by providing a decentralized version.


Ques: 13. What is Node Application? Explain in detail.

Ans: Node application is a computer application that a computer needs to be part of the ecosystem. Without the node application, it is not possible for a device to participate in blockchain activity.
There is different node application when it comes to the blockchain. Bitcoin, for example, uses the Bitcoin wallet application to make a computer compatible with the blockchain.
Technically, there is a service overlay network(SON) that interfaces between the blockchain and the computer. The computer needs to use the node application to read and reply in a specific manner,
Not all node application is free from restriction. Some blockchains are stick when allowing a node to join the application. It needs permission to do so.


Ques: 14. What are the different types of Consensus Algorithm? Explain each of them briefly.

Ans: There are three main types of consensus algorithm.
  1. Proof-of-Work(PoW): Proof-of-Work(PoW) is used by the most popular cryptocurrencies out there. Bitcoin, Ethereum, and Litecoin use it. It works by solving complex mathematical problems. The hash needs to be solved for the block to be mined. Once it is done, the transaction is validated, and the consensus is made.
  2. Proof-of-Stake(PoS): Proof-of-Stake(PoS) works by staking coins. The nodes need to stake a minimum amount of coins to become part of the consensus network. Once they become part, they actively take part in making decisions on the network. Unlike Proof-of-Work, PoS doesn’t require huge computational power, and hence power. 
  3. Delegated Proof-of-Stake(DPoS): Delegated Proof-of-Stake is a centralized approach to a blockchain network. In this consensus method, the stakes choose delegates which in turn validate the transactions.

Ques: 15. What is ‘blind signature’ and why is it used?

Ans: Blind Signature is a digital signature wherein all the information pertaining to a contract is made blind before it is actually agreed upon and sealed with a sign. This approach is a crucial component of cryptography and is mainly used for privacy-related protocols (for example, digital cash scheme) where the author and the signing parties are different.


Ques: 16. What are the fundamental principles in Blockchain that are used to eliminate security threats?
Ans: The fundamental principles in Blockchain that must be followed to eliminate security threats are:
  1. Auditing 
  2. Securing applications 
  3. Securing testing and similar approaches 
  4. Database security 
  5. Continuity planning 
  6. Digital workforce training

Ques: 17. What do you understand by the terms – ‘public key’ and ‘private key.’?

Ans: A public key is one which is used in cryptographic algorithms that allow all the users/peers in a Blockchain network to receive funds in their wallet. This key is essentially an alphanumeric string that is unique to a particular node or address.
A private key, on the other hand, is an alphanumeric phrase that is used in pair with a public key for encryption and decryption purposes. This key remains with a single individual who is the key generator for it. In case, anyone else gets their hand on the private key, the data within the wallet of the generator will be compromised.


Ques: 18. What do you mean by ‘off-chain’ transactions?

Ans: An off-chain transaction occurs when values are moved or placed outside the Blockchain. In this sense, it is merely a ‘transaction’ and not a ‘Blockchain transaction.’ Such transactions have no bearings on the values stored within the blocks of a Blockchain. 


Ques: 19. Explain ‘secret sharing.’

Ans: Secret Sharing is a method dedicated to protecting data integrity in Blockchain. In this method, the information or data is divided into different units and then transferred to the users on the Blockchain network. To complete the entire information, users who received the chunks of broken information must agree to share their pieces of information and combine them together.


Ques: 20. Explain a real-time blockchain use case?

Ans: Healthcare can use blockchain to their advantage. Many startups are currently working on a blockchain powered health app that lets patients store their information on the blockchain. The decentralized nature means that they don’t have to carry documents. Healthcare specialist can also take advantage of it as they can access the patient’s data anytime they want. Researchers also benefit from public blockchain where they can access large public data.