Docker Important interview Questions.

Docker Important interview Questions.

Day 21 #90DaysOfDevOps

What is the Difference between an Image, Container and Engine?

Docker images are immutable, which means they can't be modified once created. If changes need to be made to an image, you must create a new image with the desired modifications. In contrast, containers are mutable and allow modifications during runtime.

What is the Difference between the Docker command COPY vs ADD?

First, the ADD directive can accept a remote URL for its source argument. The COPY directive, on the other hand, can only accept local files. Note that using ADD to fetch remote files and copying is not typically ideal. This is because the file will increase the overall Docker image size.

What is the Difference between the Docker command CMD vs RUN?

RUN executes commands and creates new image layers. CMD sets the command and its parameters to be executed by default after the container is started. However CMD can be replaced by docker run command line parameters.

How Will you reduce the size of the Docker image?

Here are some basic steps recommended to follow, which will help create smaller and more efficient Docker images.

  1. USE A SMALLER BASE IMAGE FROM ubuntu. ...

  2. DON'T INSTALL DEBUG TOOLS LIKE curl/vim/nano. ...

  3. MINIMIZE LAYERS. ...

  4. USE –no-install-recommends ON apt-get install.

    Why and when to use Docker?

    It provides a viable, cost-effective alternative to hypervisor-based virtual machines, so you can use more of your server capacity to achieve your business goals. Docker is perfect for high density environments and for small and medium deployments where you need to do more with fewer resources.

    Explain the Docker components and how they interact with each other.

    It provides a viable, cost-effective alternative to hypervisor-based virtual machines, so you can use more of your server capacity to achieve your business goals. Docker is perfect for high density environments and for small and medium deployments where you need to do more with fewer resources.

    Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?

    Docker Compose is a tool for defining and running multi-container Docker applications. Using a YAML configuration file, Docker Compose allows us to configure multiple containers in one place. We can then start and stop all of those containers at once using a single command.

    In what real scenarios have you used Docker?

    Docker use case examples:

    • Microservices-based apps. Applications designed using a microservices architecture are a natural fit for Docker containers. ...

    • Pre-deployment application testing. ...

    • Early application development. ...

    • Multi-cloud or hybrid cloud applications. ...

    • Deploying OS-agnostic applications. ...

    • Cost control.

Docker vs Hypervisor?

A hypervisor allows the users to generate multiple instances of complete operating systems. Dockers can run multiple applications or multiple instances of a single application. It does this with containers.

What are the advantages and disadvantages of using docker?

Advantages:

What are the advantages of using Docker?

In conclusion, Docker provides a range of benefits for developers and operations teams, including increased efficiency, flexibility, portability, and security. By using Docker, organizations can streamline their development and deployment processes, reduce costs, and improve overall efficiency.

Disadvantage:

  • Security: Docker containers are not completely isolated from the host system. This means that if a container is compromised, the host system could also be compromised.

  • Performance: Docker containers can add overhead to the host system. ...

  • Complexity: Docker can be complex to learn and use.

What is a Docker namespace?

  1. 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?

    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?

    ENTRYPOINT is an essential tool for configuring Docker containers. It sets the default command that executes when a container starts from an image, defining its primary function. You can use ENTRYPOINT to run specific applications, help in CI/CD pipelines, or combine with CMD for more flexible container behavior.

    How to implement CI/CD in Docker?

    1. Step one: Create the repository. Create a GitHub repository, configure the Docker Hub secrets, and push your source code. ...

    2. Step two: Set up the workflow. Set up your GitHub Actions workflow for building, testing, and pushing the image to Docker Hub. ...

    3. Step three: Run the workflow.

Will data on the container be lost when the docker container exits?

Do I lose my data when the container exits? Not at all! Any data that your application writes to disk gets preserved in its container until you explicitly delete the container.

What is a Docker swarm?

Docker Swarm is a clustering and scheduling tool for Docker containers. With Swarm, IT administrators and developers can establish and manage a cluster of Docker nodes as a single virtual system. Swarm mode also exists natively for Docker Engine, the layer between the OS and container images.

What are the docker commands for the following:

  1. View running containers :

    docker ps or docker container ls

  2. command to run the container under a specific name:

    --name option

  3. command to import an already existing docker image:

    load command

  4. commands to delete a container:

    docker rmi / docker kill / docker rm

  5. command to remove all stopped containers, unused networks, build caches, and dangling images?

    docker prune