Top 100 Docker Interview Questions
The questions are divided into 6 domains as listed below :
- Installation and Configuration
- Orchestration
- Image Creation, Management, and Registry
- Networking
- Security
- Storage and Volumes
Installation and Configuration
Below are the related questions & answers :
Orchestration
Below are the related questions & answers :
Q.How to get rid of all non-running containers
===========================================================
# docker rm $( docker ps -q )
Q. Scenario to find diff (changes in the container made & compared to the image )
[2.When to create a container ? Difference between Container and Image ?]
================================================================================
#docker run -it --name testdocker5 alpine ash
# mkdir testDir
# exit
# docker diff testdocker5
o/p
# C /root
A /root/.ash_history
A /testDir
3.How to create an Image in Docker ?
=======================================
# Modify a new container
docker run --name my_container ubuntu:latest
touch /HelloWorld
# Commit the changes you made in that container
# to a new image
docker commit my_container my_image
# Remove the changed container
docker rm -vf my_container
# Test the new image docker run --rm my_image
# ls -l /HelloWorld
# Outputs:
# -rw-r--r-- 1 root root 0
# /HelloWorld
Q.A new feature of docker is now enabled, How to determine whether your docker CLI can handle it - ?
======================================================================================
Experimentail cli : USERFOLER\.docker\machine\machines\default
open config.json
mirror upgrade : docker-machine upgrade
Q.when to use between Run , Pull and Exec options in Docker ?
Q.What is default port of docker daemon ?
======================================
$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://14.354.34.100:2376"
Q.A Docker machine can talk to another Docker machine - As DevOps , What do you need ?
============================================================================
Through overlay & by network Ingress
The overlay network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely. Docker transparently handles routing of each packet to and from the correct Docker daemon host and the correct destination container.
When you initialize a swarm or join a Docker host to an existing swarm, two new networks are created on that Docker host:
an overlay network called ingress, which handles control and data traffic related to swarm services. When you create a swarm service and do not connect it to a user-defined overlay network, it connects to the ingress network by default.
a bridge network called docker_gwbridge, which connects the individual Docker daemon to the other daemons participating in the swarm.
Q.Docker Containers are persistent - Agree?
===========================================================
Yes , For every docker commit it is creating image
https://thenewstack.io/methods-dealing-container-storage/
Q.Docker Containers - Can the same image be stored in different Containers - If yes ,
what is the state of the image in Dockers , if there an option to state persistence?
==============================================================================
yes
Q.How to identify the log of the container ?
===============================================
docker inspect testdocker5
o/p
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
Q.Without Docker ps-a , is there an option to determine whether a container is in UP state
========================================================================================
docker container ls
$ docker inspect -f "{{.Name}}{{.State.Status}}" testdocker5
o/p
/testdocker5exited
$ docker inspect -f "{{.Name}}{{.State.Status}}} $(docker ps -q)
$ docker inspect -f "{{.Name}}{{.State.Status}}" $(docker ps -a -q)
/testdocker5exited
/testcont2paused
/testubn1running
/sampletestcontainerexited
docker run -dit --name testubn3 ubuntu bash
docker attache testubn3
exit
12.When Pulling the Image from HUB Docker - What is the First protocol Docker server checks
===========================================
docker info
Q.Is each Docker-machine a VM ?
=====================================
boot to docker
C:\Users\sjyetki.ORADEV\.docker\machine\machines\default
+CLI
Q.Can docker machine be associated with vairous docker drivers like hyperv, virtualbox?
===========================================================
Only one at a time
Q.Hypervisor - is Docker a replacement for Hypervisor ?
===========================================================
No , Docker brings additional services on top of Hypervisor
@.Is Docker a Freeware?
===========================================================
No
Q.What is command to measure utilization of the Docker engine ?
===========================================================
#docker run -dit --name test1 ubuntu bash
#docker stats test1
#docker top test1
Q.Dockers and VM - Do they co-exist ?
===========================================================
Yes
Q.container ID - What is length of Container ID ?
===========================================================
64 bytes
Q.Can an Image be overwritten in Docker ?
===========================================================
yes
Q. Which objects have IPs in Docker ?
===========================================================
8 objects : HOST , MACHINE , Repository , container , volume , image , registry , network
Q. What is default log driver of container ?
===========================================================
JSON
Q. How to determine the size of the running container?
===========================================================
#DIFFPATH="/var/lib/docker/aufs/diff"; \
(for d in `docker ps -q`; do du -s ${DIFFPATH}/${d}*; done;) | \
sed -e 's/-init//g' | \
awk '{ sum[$2] += $1 }; END { for (path in sum) { print sum[path]/1024"M", path } }'
Q. To delete all containers in a single step ?
===========================================================
#docker rm $( docker ps -a )
Image Creation, Management, and Registry Networking
Below are the related questions & answers :
Security
Below are the related questions & answers :