Skip to content
  • Docker Tutorial
  • Kubernetes Tutorial
  • Interview Questions
  • Windows
  • Tutorials
    • Git
    • MySQL
    • MongoDB
FOSS TechNix
  • Linux
    • Ubuntu
    • CentOS
  • Cloud
    • AWS
    • Azure
  • DevOps
    • Ansible
    • Artifactory
    • GitLab
    • Jenkins
    • SonarQube
    • Terraform
  • Containerization
    • Docker
    • Kubernetes
  • Database
    • MySQL
    • MongoDB
    • Redis
  • Scripting
    • Shell Script
  • Programming
    • Python
    • PHP
  • Monitoring
    • Nagios
    • ElasticSearch
    • Prometheus
    • Zabbix

50 Real Time Docker Interview Questions and Answers

March 9, 2021March 13, 2020 by FOSS TechNix

Home » 50 Real Time Docker Interview Questions and Answers

In this article, We are going to cover Real time Docker Interview questions and answers for Fresher and Experienced candidate.

We have friends who are working in DevOps,We have contacted them and collected below Practical docker interview questions and their answers which can be asked in interview.

Docker Interview Questions and Answers

docker interview questions and answers

1. What according to you is Docker?

A Docker can be a platform designed to ensure excellent efficiency and availability by containerizing the application and segregating them from each other for environments like production, testing or development.

2. Define Docker hub or Docker Hub Registry?

Docker hub is a cloud-based registry service that lets you attach, create and send your assets to application databases, save images that have been manually sent, and connects to Docker cloud so that you can you can deploy images to your hosts.

Docker hub provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, workflow automation throughout the development pipeline.

3. What is command to pull docker image

Syntax

$ docker pull [OPTIONS] [PATH/]IMAGE_NAME[:TAG]

Example

$ docker pull ubuntu

4. How to pull docker image with specific version

$ docker pull ubuntu:18.04

 5. How to pull the latest version of an image

$ docker pull ubuntu:latest

6. How to create a custom tag to docker image

$ docker tag ubuntu:latest fosstechnix/ubuntu:test

7. How to push  docker image to docker hub registry using command line

$ docker push fosstechnix/ubuntu:demo

8. How to Remove all images in docker server

$ docker image rm -f <Image_id>

9. How to Pull your custom image from your docker account

$ docker pull fosstechnix/ubuntu:demo

10. How to pull Docker Image from Private Registry

First login to Private Registry

$ docker login myrepo.fosstechnix.com:9000

 Then pull  your images

Syntax:

$ docker pull [OPTIONS] ADDRESS:PORT[/PATH]/IMAGE_NAME[:TAG]

 Example:

$ docker pull repo.fosstechnix.com:9000/demo-image

11. What do you mean by Docker container?

The program and all its components are included in Docker containers. The kernel is associated with several other containers and works in the host operating system as independent operations.

12. Tell me some about Hypervisor.

Hypervisor can also termed as the virtual machine monitor. This system basically divides the hosting system by delegating resources to each system equally. The possibility of turning virtualization into feasibility and practicality can be achieved only with Hypervisor.

13. Can you state the advantages of Docker over Hypervisor?

The prominent advantage of using Docker over Hypervisor is lightweight feature of the former one makes it highly feasible in terms of operations.

14. Define Docker images.

Docker images are required for establishing Docker containers. These  images can be used for linking to any of the Docking environment.

15. How do you estimate the Docker server version and the client?

$ docker version

command will give the requisite information regarding the Docker client and server version.

16. Tell me something about Docker machine.

Docker machines are basically used for clustering of Docker swarms. Moreover, they are used for installation of Docker engines on the virtual hosting facilities, which can be managed using the commands from Docker machines.

17. Define Docker Swarms.

Docker swarms functions mainly by splitting a collection of Docker hosts into individual and virtual hosting spaces. As a result, the maintenance turns very easy and feasible in its operations.

18. Describe the usage of Dockerfile?

A Dockerfile is a series of specific instructions something we must send Docker to create the files. We can see the Dockerfile as a word document that has all the required commands to build a Docker Image.

OR

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Below is workflow to create Docker Container from Dockerfile

Dockerfile –> Docker Image –> Docker Container

19. Can you please write Dockerfile to create Ubuntu Docker Image

FROM ubuntu:18.04
MAINTAINER FOSS TECHNix support@fosstechnix.com
LABEL version="1.0" \
RUN apt-get update && apt-get install -y apache2 && apt-get clean
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
COPY index.html /var/www/html
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]

20. Can you please write Dockerfile to create Node Js Docker Image

FROM node:10
RUN mkdir -p /home/nodejs/app
WORKDIR /home/nodejs/app
COPY package.json .
RUN npm install
COPY . .
CMD [“node.js”, “index.js”]
EXPOSE 3000

21. What is command to build docker image from Dockerfile ?

$ docker build -t image_name .

22. What is the command to run the image as a container?

$ docker run -it ubuntu /bin/bash

Here i -> interactive, t -> terminal

23. What is command to list docker images

$ docker images

24. What is command to list specific docker image

$ docker image ls <imagename>

25. How to apply port mapping a running container?

We can apply port forwarding while running a container using below command.

$ docker run -p <public_port>:<private_port> -d <image>

26. What is command to login docker container

$ docker exec -it <container_Name> /bin/bash

27. What is command to stop a docker container

$ docker stop <container_id>

28. What is command to start a docker container

$ docker start <container_id>

29. What is command to remove a Docker container

$ docker rm <container_id>

30. What is command to list out Running Docker containers

$ docker ps

31. What are the common instructions in Dockerfile

Below are some common instructions in Dockerfile

FROM, MAINTAINER, RUN, CMD, LABEL, EXPOSE, ENV, ADD, COPY, ENTRYPOINT, VOLUME, USER, WORKDIR, ARG, ONBUILD, STOPSIGNAL, SHELL, HEALTHCHECK

32. What is difference between ADD and COPY in Dockerfile

COPY : Copies a file or directory from your host to Docker image, It is used to simply copying files or directories into the build context.

Syntax:

COPY <source> <destination>

Example:

COPY index.html /var/www/html

ADD: Copies a file and directory from your host to Docker image, however can also fetch remote URLs, extract TAR/ZIP files, etc. It is used downloading remote resources, extracting TAR/ZIP files.

Syntax:

ADD <source> <destination>

Example:

ADD java/jdk-8u231-linux-x64.tar  /opt/jdk/

33. Detail us with some of the specific advantages of Docker over other containerization technologies.

  • Different types of files can be downloaded from a central space along with the Docker hub.
  • Docker also enables us to share our contents with our created containers.
  • It can be assessed from the official IT systems or even from the personal computers also.

34. Enumerate the lifecycle process of Docker containers

  • Establishing the containers.
  • Using the container.
  • Pausing
  • Unpausing
  • Halting the container.
  • Restarting
  • Destroying the container.

35. What are Docker Namespaces?

Docker Namespaces is a platform that provides a container known as independent workspaces. A variety of namespaces are generated for this database after a container is launched.

Such namespaces include a seclusion framework for the containers since each container operates in a different namespace with limited access to the namespace defined.

36. What is the EXPOSE command? What is its role?

EXPOSE <port> [<port>/<protocol>...]

During publishing of the ports, this command can be used for mapping of the documentations.

37. Why is it necessary to monitor a Docker?

Active monitoring ensures higher productivity and better outcomes. Docker monitoring also notifies about any default in the system.

38. Define Docker compose?

Docker Compose is a method for specifying various containers and their parameters in a YAML or JSON. Docker Compose more usually uses one or several dependencies, for instance MySQL or MongoDB, for your program.

This dependencies are usually set up locally throughout innovation — a process which then has to be reworked before going to a production set-up. You can use Docker Compose to prevent these deployment and configuration bits.

OR

Docker compose is used to Defining and Running multi container Docker Application, you can use JSON or YAML file to write docker compose

39. Can Please create Nodejs, MySQL, MongoDB docker environments using docker-compose file ?

version: "2"
services:
web:
build: .
ports:
- "3000:3000"
depends_on:
- mongo
- mysql
mongo:
image: mongo
volumes:
- my-datavolume:/var/lib/mongo
volumes:
my-datavolume:
ports:
- "27017:27017"
mysql:
env_file:
- mysql-server.env
image:mysql
volumes:
- my-datavolume:/var/lib/mysql
volumes:
my-datavolume:
ports:
- "3306:3306"

40. What is command to run Docker compose

$ docker-compose up

41. What is depends_on in Docker compose

It is used to Link to containers in another service and also express dependency between services.

42. Can We use JSON instead of YAML for my compose file in Docker

Yes. We can Use.

43. Describe the role of Docker load and save command.

Docker save command makes its possible to export a Docker image as an archive with command:

$ docker save -o <container-export-path>.tar <container-name>

44. While this exported image can be easily imported to other hosts using the load command.

$ docker load -i <container-path>.tar

45. Why and how to identify the status of a Docker container?

Identification of the status helps us to make any conduct to the Docker containers accordingly. Therefore, for identifying the same we need to run the following command.

$ docker ps –a

46. Which is the most feasible type of application for Docker containers – Stateless or Stateful?

It is best to generate a Stateless Docker container application. From our code we could build a container and remove programmable state parameters from framework. Now in development and in QA environments we can operate the same container with different parameters.

This allows to recreate the same image in various scenarios. A stateless framework is also much simpler than a superb program to scale with Docker Containers.

47. Differentiate between a Docker layer and a image.

The layers in a Docker represents the set of instructions from a Docker image, while the image is nothing but the set of read-only layers.

48. Say something about virtualization.

A way of logically separating mainframes is seen as virtualization what allows multiple software to run concurrently. The situation changed radically, though, as businesses and open source networks could provide a way to handle delegated instructions in one manner or another, allowing multiple operating systems to operate on a single x86-based machine concurrently.

49. What if you have accidentally out of the Docker containers, will you loose the files?

There is no way we can loose our progress in a Docker container unless we have implemented the deleting program in the container itself.

50. What are factors that decides the number of containers you can run on?

Factors such as app size and strength of the CPU can deliberately influence the count of Docker containers. Thus, it can be understood that if we are equipped goof CPU strength we can easily hell load of containers with extreme ease.

51. What is the difference between CMD and ENTRYPOINT in a Dockerfile?

CMD in Dockerfile Instruction is used to execute a command in Running container, There should be one CMD in a Dockerfile.

ENTRYPOINT in Dockerfile Instruction is used you to configure a container that you can run as an executable.

52. What is Dockerfile Instructions ?

Dockerfile contains a set of Instructions to build Docker Image -> from Docker Image -> running Docker container

We have covered docker interview questions and answers for fresher and experienced candidate.

53. What are Docker Lifecycle commands ?

Below are some Docker Lifecycle commands for every Docker Container

  1. Docker create
  2. docker run
  3. docker pause
  4. docker unpause
  5. docker stop
  6. docker start
  7. docker restart
  8. docker attach
  9. docker wait
  10. docker rm
  11. docker kill

54. What is Docker Prune ?

Using Docker prune we can delete unused or dangling containers, Images , volumes and networks

Conclusion:

We have covered docker interview questions and answers for fresher and experienced candidate.

Related Articles

Docker Tutorial for Beginners step by step

Jenkins Interview Questions for DevOps Engineer

50 Real Time Kubernetes Interview Questions and Answers

How to Install Docker on Windows 10

100 Docker Basic Commands with Examples

What does DevOps Engineer do ?

Reference:

https://docs.docker.com/get-started/

Sharing is Caring:

0 Shares
  • Facebook 0
  • Twitter
  • LinkedIn
  • Email
  • More
How to Setup Apache Virtual Host on Ubuntu 18.04/16.04 LTS
How to Install Oracle Java 12 on Ubuntu 19.04/18.04/16.04 LTS
FOSS TechNix

FOSS TechNix (Free,Open Source Software's and Technology Nix*) founded in 2019 is a community platform where you can find How-to Guides, articles for DevOps Tools,Linux and Databases.

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

RECENT POSTS

  • How to Validate Jenkinsfile using Visual Studio Code
  • How to Install GitLab Runner on Ubuntu 22.04 LTS
  • How to Install Apache2 on Ubuntu 22.04 LTS
  • How to Install MySQL 5.7 on Ubuntu 22.04 LTS
  • Build and Push Docker Image to AWS ECR Using GitHub Actions

About Foss TechNix

FOSS TechNix (Free ,Open Source Softwares and Technology Nix*) is a community site where you can find How-To Guides, Articles, Tips and Tricks for DevOps Tools, Linux, Databases, Clouds and Automation.

facebook pinterest linkedin youtube

DEVOPS TOOLS & TIPS

  • What does DevOps Engineer do ?
  • Top 11 Open Source Monitoring Tools for Linux

Tutorial for Beginners

  • Docker Tutorial for Beginners
  • Kubernetes Tutorial for Beginners
ABOUT | CONTACT | TOC | PRIVACY

© 2023 FossTechNix - Designed by Navin Rao
Share via
Facebook
Twitter
LinkedIn
Mix
Email
Print
Copy Link
Powered by Social Snap
Copy link
CopyCopied
Powered by Social Snap