Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Docker Interview Questions and Answers

Ques 1. What is Docker?

Docker is a containerization platform that allows developers to package, distribute, and run applications in isolated environments called containers.

Example:

docker run -d -p 80:80 nginx

Is it helpful? Add Comment View Comments
 

Ques 2. Explain the difference between an image and a container.

An image is a lightweight, standalone, and executable package that includes everything needed to run a piece of software. A container is an instance of a running image.

Example:

docker create my_image

Is it helpful? Add Comment View Comments
 

Ques 3. What is the purpose of Dockerfile?

Dockerfile is a script that contains instructions for building a Docker image. It specifies the base image, application code, dependencies, and other configurations.

Example:

FROM ubuntu
RUN apt-get update && apt-get install -y nginx

Is it helpful? Add Comment View Comments
 

Ques 4. How do you link containers in Docker?

Docker provides network options like --link and user-defined networks to connect containers. The --link option is now considered legacy, and user-defined networks are recommended.

Example:

docker network create my_network

docker run --network my_network --name container1 my_image1
docker run --network my_network --name container2 my_image2

Is it helpful? Add Comment View Comments
 

Ques 5. Explain Docker Compose.

Docker Compose is a tool for defining and running multi-container Docker applications. It uses a YAML file to configure the application's services, networks, and volumes.

Example:

version: '3'
services:
  web:
    image: nginx
    ports:
      - '80:80'

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook