Day 21 Task: Docker Important interview Questions.
Docker Interview
Docker is a good topic to ask in DevOps Engineer Interviews, mostly for freshers. One must surely try these questions in order to be better in Docker
Questions
What is the Difference between an Image, Container and Engine?
The key difference between a Docker image vs a container is that a Docker image is a template that defines how a container will be realized. A Docker container is a runtime instance of a Docker image. Docker Engine is an open source containerization technology for building and containerizing your applications.
What is the Difference between the Docker command COPY vs ADD?
COPY and ADD are both Dockerfile instructions that serve a similar purpose. They let you copy files from a specific location into a Docker image.
COPY takes in a source and destination. It only lets you copy in a local or directory from your host (the machine-building the Docker image) into the Docker image itself.
What is the Difference between the Docker command CMD vs RUN?
RUN is an image build step, the state of the container after a RUN command will be committed to the container image. A Dockerfile can have many RUN steps that layer on top of one another to build the image.
CMD is the command the container executes by default when you launch the built image. A Dockerfile will only use the final CMD defined. The CMD can be overridden when starting a container with docker run $image $other_command.
How Will you reduce the size of the Docker image?
Increase docker storage size
Why and when to use Docker?
The value of Docker for DevOps continues as it enables an entirely isolated application to be deployed to multiple servers. As it spreads to the servers, no other applications can access it. The only exposure of the container is to the internet and the Docker client.
We can use Docker to wrap up an application in such a way that its deployment and runtime issues—how to expose it on a network, how to manage its use of storage and memory and I/O, how to control access permissions—are handled outside of the application itself, and in a way that is consistent across all “containerized
Explain the Docker components and how they interact with each other.?
Docker works via a Docker engine that is composed of two key elements: a server and a client; and the communication between the two is via REST API. The server communicates the instructions to the client.
Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?
Docker Compose: A command-line tool and YAML file format with metadata for defining and running multi-container applications. You define a single application based on multiple images with one or more .yaml files that can override values depending on the environment. After you've created the definitions, you can deploy the whole multi-container application with a single command (docker-compose up) that creates a container per image on the Docker host.
Dockerfile: A text file that contains instructions for building a Docker image. It's like a batch script, the first line states the base image to begin with and then follow the instructions to install required programs, copy files, and so on, until you get the working environment you need.
Docker image: A package with all the dependencies and information needed to create a container. An image includes all the dependencies (such as frameworks) plus deployment and execution configuration to be used by a container runtime. Usually, an image derives from multiple base images that are layers stacked on top of each other to form the container's filesystem. An image is immutable once it has been created.
Docker Container: An instance of a Docker image. A container represents the execution of a single application, process, or service. It consists of the contents of a Docker image, an execution environment, and a standard set of instructions. When scaling a service, you create multiple instances of a container from the same image. Or a batch job can create multiple containers from the same image, passing different parameters to each instance.
In what real scenarios have you used Docker?
Docker is one of the recent most successful open source project which provides packaging, shipping, and running any application as light weight containers. We can actually compare Docker containers as shipping containers that provides standard consistent way of shipping any application.
Docker vs Hypervisor?
Hypervisors are of two types – the bare metal works directly on the hardware while type two hypervisor works on top of the operating system.
Recommended by LinkedIn
Docker, on the other hand, works on the host kernel itself. Hence, it does not allow the user to create multiple instances of operating systems.
What are the advantages and disadvantages of using docker?
Advantages of Docker
Disadvantages of Docker
What is a Docker namespace?
Docker uses a technology called namespaces to provide the isolated workspace called the container. When you run a container, Docker creates a set of namespaces for that container. These namespaces provide a layer of isolation.
What is a Docker registry?
A Docker registry is a storage and distribution system for named Docker images. The same image might have multiple different versions, identified by their tags. A Docker registry is organized into Docker repositories , where a repository holds all the versions of a specific image.
What is an entry point?
A particular place where a person or thing can enter something or somewhere. The site has several entry points. entry point to something The emergency services closed all entry points to the square.
How to implement CI/CD in Docker?
2. Open the repository Settings, and go to Secrets > Actions.
3. Create a new secret named DOCKERHUB_USERNAME and your Docker ID as value.
4. Create a new Personal Access Token (PAT) for Docker Hub.
Will data on the container be lost when the docker container exits?
After a container finishes executing its default command, it will stop. When you run a container image you've pulled from a registry like Docker Hub, you're launching a process. This process will, eventually, complete.
What is a Docker swarm?
A Docker Swarm is a group of either physical or virtual machines that are running the Docker application and that have been configured to join together in a cluster. The activities of the cluster are controlled by a swarm manager, and machines that have joined the cluster are referred to as nodes.
What are the docker commands for the following:
What are the common docker practices to reduce the size of Docker Image?
These questions will help you in your next DevOps Interview.
Happy Learning :)
Great
Practice makes a man perfect
good work