Friday 22 July 2022

Top 30 Docker Interview questions for DevOps-SDET-QAE? Must know concepts of Dockerfile? How to create Docker Image?

 



Check post for MAVEN commands and Interview Question:

MAVEN Commands

Docker Commands: Interview Question

Pre-Requisite:


MUST KNOW COMMANDS OF DOCKER


Lets start with top 30 Docker interview questions and answers

1. Difference between CMD and ENTRYPOINT

TL;DR CMD will work for most of the cases.

Default entry point for a container is /bin/sh, the default shell.

Running a container as docker container run -it ubuntu uses that command and starts the default shell. The output is shown as:

> docker container run -it ubuntu
root@88976ddee107:/#

ENTRYPOINT allows to override the entry point to some other command, and even customize it. For example, a container can be started as:

> docker container run -it --entrypoint=/bin/cat ubuntu /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
. . .

This command overrides the entry point to the container to /bin/cat. The argument(s) passed to the CLI are used by the entry point.


2. How to create your first docker image using Java:

CLICK HERE for all the steps with screenshots


3. Difference between ADD and COPY

TL;DR COPY will work for most of the cases.


ADD has all capabilities of COPY and has the following additional features:

  1. Allows tar file auto-extraction in the image, for example, ADD app.tar.gz /opt/var/myapp.

  2. Allows files to be downloaded from a remote URL. However, the downloaded files will become part of the image. This causes the image size to bloat. So its recommended to use curl or wget to download the archive explicitly, extract, and remove the archive.


4. Import and export images

Docker images can be saved using image save command to a .tar file:

docker image save helloworld > helloworld.tar

These tar files can then be imported using load command:

docker image load -i helloworld.tar
What is Dockerfile? Dockerfile

Docker build images by reading instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. docker image build command uses this file and executes all the commands in succession to create an image.

build command is also passed a context that is used during image creation. This context can be a path on your local filesystem or a URL to a Git repository.


What is the difference between VM and Doker?

Virtual machines have a full OS with its own memory management installed with the associated overhead of virtual device drivers. In a virtual machine, valuable resources are emulated for the guest OS and hypervisor, which makes it possible to run many instances of one or more operating systems in parallel on a single machine (or host). Every guest OS runs as an individual entity from the host system. Hence, we can look at it an independent full-fledge house where we don't share any resources

In the other hand, Docker containers are executed with the Docker engine rather than the hypervisor. Containers are therefore smaller than Virtual Machines and enable faster start up with better performance, less isolation and greater compatibility possible due to sharing of the host’s kernel. Hence, it looks very similar to residental flats system where we share resources of the building.




Source reference: collabnix/dockerlabs

How to connect to remote Docker Daemon?

Click Here For Steps with Screenshots


What are the common commands for Dockerfile?


Common commands for Dockerfile



************************************************ 
 

*************************************************

How is Dockerfile different from Docker Compose?

A Dockerfile is a simple text file that contains the commands a user could call to assemble an image whereas Docker Compose is a tool for defining and running multi-container Docker applications. 

Docker Compose define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment. It get an app running in one command by just running docker-compose up. 

Docker compose uses the Dockerfile if one add the build command to your project's docker-compose.yml. Your Docker workflow should be to build a suitable Dockerfile for each image you wish to create, then use compose to assemble the images using the build command.

How to setup docker with selenium grid for cross browser testing?



What is the maximum number of containers you can run per host?

This really depends on your environment. The size of your applications as well as the amount of available resources (i.e like CPU) will all affect the number of containers that can be run in your environment. Containers unfortunately are not magical. 

They can’t create new CPU from scratch. They do, however, provide a more efficient way of utilizing your resources. The containers themselves are super lightweight (remember, shared OS vs individual OS per container) and only last as long as the process they are running.

What is Docker Swarm?

Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. 

Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.

Does Docker Swarm do load balancing?

Yes, Docker Swarm does load balancing. Docker Swarm's load balancer runs on every node and is capable of balancing load requests across multiple containers and hosts.


Know About Docker Containers:


5. docker run -it -d <Image-Name> -> 
To Create Docker Container from Docker Image.

6.
docker start <Container-Id> ->
 To Start Container.

7.
docker restart <Container-Id> -> 
To Restart Container.

8. docker stop <Container-Id> -> 
To Stop Container when in Running.

9. docker rm <Container-Id> -> 
To Delete Docker Container

*******************************************************************
For any doubts or career guidance, arrange a 1:1 call with me 


********************************************************************


Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122
Entire course content can be found below:  COURSE CONTENTCheck below link for question and answers with code:

  • Interview questions for SDET/Automation Testing:
  • Top 21 GIT interview questions
  • Top 30 Selenium Webdriver Interview Q&A 
  • Top 20 API Testing Interview Q&ASelenium Interview Question SET-4 
  • Selenium Interview Question SET-1
  • Selenium Interview Question SET-2
  • Selenium Interview Questions SET-3
  • Selenium Interview Question SET-4 
  • *************************************************

    API Testing Interview Question Set:
    https://automationreinvented.blogspot.com/search/label/Rest-API

     
    Kubernetes Interview Question Set
    https://automationreinvented.blogspot.com/search/label/Kubernetes

     
    Docker Interview Question Set
    https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

     
    Linux Interview question Set
    https://automationreinvented.blogspot.com/search/label/Linux

     
    Automation Testing/SDET Framework Design
    https://automationreinvented.blogspot.com/search/label/FrameworkDesign


    Java Related Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Java


    GIT Interview Question Set:
    https://automationreinvented.blogspot.com/search/label/GIT


    Coding Interview Question Set:
    https://automationreinvented.blogspot.com/search/label/Coding%20Questions

    No comments:

    Post a Comment

    All Time Popular Posts

    Most Featured Post

    Scenario Based Frequently Asked Interview Q&A on TestNG

      🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl Welcome to our compr...