Day 21 - Navigating Crucial Docker Interview Questions! ππ³
What is the Difference between an Image, Container, and Engine?
Answer: An image is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the code, a runtime, libraries, and settings. A container is a runtime instance of an image. An engine is a client-server application with a REST API used to build and run containers. πΌοΈπ³π§
What is the Difference between the Docker command COPY vs ADD?
- Answer: The COPY command copies files or directories from a source to a destination in the container. The ADD command also copies files or directories but supports additional features like local-only tar extraction. πβ‘οΈπ¦
What is the Difference between the Docker command CMD vs RUN?
- Answer: The CMD instruction sets the default command to run when a container starts, while the RUN instruction executes commands during the build. πββοΈπ οΈ
How Will you reduce the size of the Docker image?
- Answer: To reduce Docker image size, use a smaller base image, minimize the number of layers, and clean up unnecessary files and dependencies. π³π
Why and when to use Docker?
- Answer: Docker is used for containerization, enabling consistent, lightweight, and portable software deployment across various environments. ππ
Explain the Docker components and how they interact with each other.
- Answer: Docker components include Docker Engine, Images, Containers, Docker Hub, and Docker Compose. They interact through the Docker API and CLI. π§π³π
Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?
Answer: Docker Compose is a tool to define and run multi-container Docker applications. Docker File is a script that contains instructions for building a Docker image. Docker Image is a lightweight, executable package with everything needed to run a piece of software. Docker Container is a runtime instance of a Docker image. πππ³π¦
In what real scenarios have you used Docker?
- Answer: Docker is often used for application deployment, microservices architecture, continuous integration, and scalability in real-world scenarios. ππ’π»
Docker vs Hypervisor?
Answer: Docker uses containerization, which is lightweight and shares the host OS, while a Hypervisor creates virtual machines with separate OS instances. π³ππ
What are the advantages and disadvantages of using Docker?
- Answer: Advantages include portability, resource efficiency, and scalability. Disadvantages may include security concerns and a learning curve. πππ
- What is a Docker namespace?
- Answer: A Docker namespace provides isolation for containers, allowing them to have their own view of the system resources. πππ
- What is a Docker registry?
- Answer: A Docker registry is a storage and content delivery system for named Docker images. Docker Hub is a popular public registry. π¦πΎπ
- What is an entry point?
- Answer: The entry point is a command that specifies the default executable for a container, defining what happens when the container starts. πͺπββοΈπ³
- How to implement CI/CD in Docker?
- Answer: Implement CI/CD in Docker by integrating Docker into CI/CD pipelines, automating builds, tests, and deployments. ππ§π
- Will data on the container be lost when the docker container exits?
- Answer: Yes, by default, data in a container is ephemeral and gets lost when the container exits. Use volumes to persist data. π¦βπ
- What is a Docker swarm?
Answer: A Docker swarm is a group of machines running Docker that work together, forming a cluster to provide high availability and scaling. π³π₯π
- What are the docker commands for the following:
View running containers:
docker ps
Command to run the container under a specific name:
docker run --name mycontainer
Command to export a docker:
docker export
Command to import an already existing docker image:
docker import
Commands to delete a container:
docker rm
Command to remove all stopped containers, unused networks, build caches, and dangling images:
docker system prune -a
π³ππ§
- What are the common Docker practices to reduce the size of Docker Image?
- Answer: Practices include using smaller base images, optimizing layers, removing unnecessary files, and using multi-stage builds. π³ππ οΈ
Subscribe to my newsletter
Read articles from Nilkanth Mistry directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nilkanth Mistry
Nilkanth Mistry
Embark on a 90-day DevOps journey with me as we tackle challenges, unravel complexities, and conquer the world of seamless software delivery. Join my Hashnode blog series where we'll explore hands-on DevOps scenarios, troubleshooting real-world issues, and mastering the art of efficient deployment. Let's embrace the challenges and elevate our DevOps expertise together! #DevOpsChallenges #HandsOnLearning #ContinuousImprovement