Questions
What is the Difference between an Image, Container and Engine?
What is the Difference between the Docker command COPY vs ADD?
What is the Difference between the Docker command CMD vs RUN?
How Will you reduce the size of the Docker image?
Why and when to use Docker?
Explain the Docker components and how they interact with each other.
Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?
In what real scenarios have you used Docker?
Docker vs Hypervisor?
What are the advantages and disadvantages of using docker?
What is a Docker namespace?
What is a Docker registry?
What is an entry point?
How to implement CI/CD in Docker?
Will data on the container be lost when the docker container exits?
What is a Docker swarm?
What are the docker commands for the following:
view running containers
command to run the container under a specific name
command to export a docker
command to import an already existing docker image
commands to delete a container
command to remove all stopped containers, unused networks, build caches, and dangling images?
What are the common docker practices to reduce the size of Docker Image?
What is the Difference between an Image, Container and Engine?
- Docker Engine is the underlying technology that enables the creation and management of Docker Containers. Docker Image is a lightweight, stand-alone, and executable package that includes everything needed to run a piece of software, such as code, libraries, and dependencies. Docker Container is an instance of a Docker Image that is running as a process in isolation from other processes on the host machine.
- What is the Difference between the Docker command COPY vs ADD?
- Both COPY and ADD commands copy files and directories from the host machine to the Docker image. However, ADD command can also download files from URLs and unpack compressed files while copying. COPY is recommended for simple file copying, while ADD is used for more complex scenarios.
- What is the Difference between the Docker command CMD vs RUN?
- RUN is used to execute commands during the Docker build process to install and configure software in the Docker Image. CMD, on the other hand, is used to define the default command to be executed when a Docker Container is started from the Docker Image.
- How Will you reduce the size of the Docker image?
Some common practices to reduce the size of the Docker image include:
Using smaller base images like Alpine Linux
Removing unnecessary files and dependencies
Combining multiple RUN commands into a single one to reduce the number of image layers
Using .dockerignore file to exclude files and directories that are not needed in the Docker Image
- Why and when to use Docker?
- Docker is used to package, distribute, and run applications in a standardized way across different environments. Docker enables developers to create isolated and reproducible development, testing, and production environments, improving collaboration, scalability, and portability of applications.
- Explain the Docker components and how they interact with each other.
Docker consists of three main components:
Docker Engine: The core component that runs and manages Docker Containers.
Docker Image: A lightweight and executable package that includes all the dependencies and configurations required to run an application.
Docker Container: An isolated and portable runtime environment that runs a Docker Image as a process.
- Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?
Docker Compose: A tool used to define and run multi-container Docker applications.
Docker File: A script used to build a Docker Image, which includes a list of commands to create the image.
Docker Image: A lightweight and standalone executable package that includes everything needed to run a piece of software, such as code, libraries, and dependencies.
Docker Container: An instance of a Docker Image that is running as a process in isolation from other processes on the host machine.
- In what real scenarios have you used Docker?
some real-world scenarios where Docker is used include:
Creating a portable and reproducible development environment for software development teams
Deploying and scaling microservices-based architectures in production environments
Running legacy applications in isolated and secure environments
- In what real scenarios have you used Docker?
- Docker uses the host machine's kernel to run Docker Containers, whereas Hypervisors use their own kernel to create and run Virtual Machines. Docker provides a more lightweight and efficient way to run applications by avoiding the overhead of running a full-fledged operating system.
- What are the advantages and disadvantages of using docker?
Advantages:
No pre-allocation of RAM
CI Efficiency- Docker enables you to build a container image and use that same image across every step of the deployment process.
Less Cost
It is light in weight
It can run on physical Hardware, Virtual Hardware, or on cloud
You can re-use the image.
It took very less time to create the container
Disadvantages:
Docker is not a good solution for application that requires a rich GUI.
Difficult to manage a large number of containers.
Docker does not provide cross-platform compatibility means if an application is designed to run in a docker container on windows, then it can't run on Linux or vice-versa.
Docker is suitable when the development O.S and testing O.S are the same, if the O.S is different, we should use Virtual Machine.
No solutioin for Data Recovery & Backup
- What is a Docker namespace?
- Docker namespaces provide a way to isolate system resources such as processes, users, network interfaces, and file systems. Each Docker container runs in its own namespace, which provides a secure and isolated environment for the application.
- What is a Docker registry?
- A Docker registry is a central repository for storing and distributing Docker images. It allows users to share and reuse images, as well as manage access and permissions.
- What is an entry point?
- An entry point is a Docker command that specifies the default command to run when a container is started. It's typically used to start the application inside the container.
- How to implement CI/CD in Docker?
- To implement CI/CD in Docker, you can use a continuous integration/continuous deployment (CI/CD) tool like Jenkins, CircleCI, or Travis CI. These tools can automatically build, test, and deploy Docker images to a production environment.
- Will data on the container be lost when the docker container exits?
- By default, any data stored inside a Docker container is lost when the container exits. However, you can use Docker volumes to persist data outside of the container, allowing it to be shared between multiple containers or persisted between container restarts.
- What is a Docker swarm?
- Docker swarm is a clustering and orchestration tool for Docker. It allows multiple Docker hosts to be grouped together into a single virtual Docker host, which can be used to deploy and manage Docker containers at scale.
What are the docker commands for the following:
view running containers
command to run the container under a specific name
command to export a docker
command to import an already existing docker image
commands to delete a container
command to remove all stopped containers, unused networks, build caches, and dangling images?
View running containers:
docker ps
Command to run the container under a specific name:
docker run --name <container_name> <image_name>
Command to export a docker:
docker export <container_id> > <output_file>
Command to import an already existing docker image:
docker import <input_file> <repository_name>:<tag>
Commands to delete a container:
docker rm <container_id>
ordocker rm <container_name>
Command to remove all stopped containers, unused networks, build caches, and dangling images:
docker system prune
- What are the common docker practices to reduce the size of Docker Image?
Use a smaller base image: Choose a lightweight base image that only includes the required dependencies for the application.
Remove unnecessary files and directories: Remove any files or directories that are not required by the application.
Minimize the number of layers: Combine multiple commands into a single layer to minimize the number of layers in the Docker image.
Use multi-stage builds: Use multi-stage builds to create intermediate images that are used to build the final image, then remove any unnecessary files from the final image.
Avoid installing unnecessary packages: Only install packages that are required by the application, and remove any unused dependencies.
Use Alpine Linux as the base image: Alpine Linux is a small and lightweight base image that is optimized for Docker.
THAT'S ALL FOR TODAY'S LEARNING I HOPE YOU LEARN SOMETHING FROM THIS BLOG