Docker Interview Questions and Answers

50+ TOP Docker Interview Questions and Answers

Docker Interview Questions
Docker Interview Questions

1) Why we need to go for Docker?
Docker is light weight and more efficient in terms of resources because it uses the host underlying kernal rather than creating it’s own hypervisor.

2)How to build environment-agnotic systems with Docker?
There are three main features
Environment Variable Injection
Read Only file systems

3) What are the most common instructions in Dockerfile?

4) Explain about docker workflow?
It starts with docker file and need to build it to create image of the container then redistribute it using registry and run the containers.

5) Explain about Docker Swarm?
Docker Swarm is native gathering for docker. It is used to group of Docker hosts into a single and virtual docker host. It provides the standard docker application program interface.

6) How to monitor the docker in production environments?
Docker stats and Docker Events

7) Why docker compose does not wait for a container to be ready before moving on to start next service in dependeny order?
Docker compose starts in a such a order based on the link volumes form and network mode.

8) Which Of the following options is correct with respect to cresting docker containers.
I can build my own image and use it for creating a Docker Container( V)
I can pull an image from docker Hub and then run docker images(v)
I can directly create a docker container without docker image(x)

9) How does the communication happen between Docker client and Docker Daemon.
Combination of Rest API, Socket.IO and TCP

10) Where does the docker daemon store the Docker images?
Docker Registry

11) What are the various states of the Docker container?
Four States: Running, Paused, Restarting and Exited.

12) Explain about configure networking in Docker?
bridge: The default network driver
host: For stand alone containers , remove network isolation between the container and the docker host
Overlay: Overlay networks connect multiple docker daemons
macvlan: for assigning MAC address for container
none: disable all neworking

13) Where the docker volumes are stored?

14) What is Docker object labels?
These are the mechanism for applying metadata to docker objects including, images, containers, Local daemons, volumes, network, swam nodes,swarm services.

15) How to start containers automatically?
We need to use restart policy …example …docker run always.
Become a Docker Expert with Certification in 25hours

16) write a Docker file to create and copy a directory and build it using python modules
FROM pyhton:2.7-slim
COPY . /app
docker build –tag

17) How to publish the image?
docker push username/repository:tag

18) How to scale the app?
By changing the replicas value in docker compose.yml and re run the command docker stack deploy.

19) How to create a vm’s in Docker?
by using this command docker-machine create –driver virtual box myvm1.

20) How to install Docker?
yum install docker

21) What is the docker inspect do?
It will give the more information about container in json format.

22) How you implement CI/CD using Docker?
Run jenkins on docker
Run integration tests jenkins using docker-compose

23)Explain about CLI’s in Docker?
Engine CLI, Compose CLI, Machine CLI, DTR(Docker Trusted Registry)CLI ,UCP (Universal Control Pane) CLI.

24) How to cleanup Docker image?
docker container stop name
docker container rm name
docker image rm name

25) How to start Docker daemon?
dockerd [options]

26) How to get Docker performance?
docker stats or docker top

27) How to check container logs?
docker logs

28) How to install logging driver plugin?
docker plugin install <org/imgname>

29) how to log tags for logging driver?
We have to use tag option
docker run –log-driver=fluentd –log-opt fluentd-address=myhost.local:24224 –log-opt tag=”mailer”

30) Explain about Docker security?
4 aspects
Kernal namespaces
control groups
docker daemon attack surface
Linux kernal capabilities
Get 100% Docker Practical Training

31) How to check the container status ?
docker ps

32) How you manage Docker images?
Using Docker Hub and Docker Registry

33) How you execute multiple Docker commands?
docker run image /bin/bash -c “cd /path/; python”

34) When you will use Docker swarm?
If we want to manage container scheduling over multiple hosts we will go for docker swarm.

35) How you create jenkins image using Docker?
Docker pull jenkins

36) what are the advantages of Docker?
1. Return on investment and cost saving
Standardization and productivity
CI/CD and efficiency
Simple and Secure

37) What is the Docker container life cycle?
Build, Pull and Run

38) How to develop new apps on Docker? an image file to docker file
2.use multistage builds
3.manage application data using and bind mounts
4.scale app as a swarm

39) which version of Docker you are using?
we can find using docker version command 19.03

40) How to control Docker with systemd?
systemctl start/stop docker
service docker start/stop

41) Explain about Docker object labels?
It is for applying metadata to docker objects including images, containers, local daemons , volumes, Networks,swarm nodes and swarm services.

42) How to clean up Docker objects?
docker image prune and docker container prune

43) How do we share Docker containers with different nodes?
By using docker swarm . Docker swarm consists of two type of nodes. one is manager node and other is worker node.

44) What is the command to create a docker swarm?
docker swarm init –advertise-addr <manager IP>

45) How to run multiple containers using single service?
By using docker compose. Each container runs seperately but they can interact with each other. All docker compose files uses yaml language.

46) Do you know how to use json instead of yaml compose file?
docker-compose -f docker-compose.json up

47) How to include code with copy/add or volumes?
In docker file we have to use COPY or ADD directive. this is useful to relocate code. we should use a volume if we want to make changes.

48) How to push the new image to Docker registry?
docker push myorg/myimg

Frequently Docker Interview Questions and Answers