Cyberithub

50 Best Docker Interview Questions and Answers

Table of Contents

Advertisements

In this article, I will take you through 50 Best Docker Interview Questions and Answers. Docker is a very frequently used tool for creating containerized environment to deploying application and services. It is very important to go through docker interview questions to understand the type of questions which generally gets asked in Interviews. Docker Interview Questions are very important to those who are planning to build their career in DevOps domain. I will bring more Docker Interview Questions in upcoming articles.

50 Best Docker Interview Questions and Answers

Docker Interview Questions and Answers

Also Read: How to Manage Ports in Docker

1. What is Docker Hub ?

Ans. It is a docker public registry where you can push your image to the Internet.

2. Which command is used to login to docker hub registry account ?

Ans. docker login

3. What is default permission given to .docker file in home directory ?

Ans. 0600

4. In which file docker will look for hostname for registry authentication ?

Ans. /home/user/.docker/config.json

5. Which command is used to upload the image to the docker repository ?

Ans. docker push

6. Which command is used to download the image from docker repository ?

Ans. docker pull

7. Which command is used to build the docker image ?

Ans. docker build

8. Which are the commands docker run will start at the background ?

Ans. docker create and docker start

9. How to remove all untagged images in docker ?

Ans. docker rmi $(docker images -q -f "dangling=true")

10. How to remove all containers that exited with a Non zero state ?

Ans. docker rm $(docker ps -a -q --filter 'exited!=0')

11. How to remove all the images from a docker node ?

Ans.docker rmi $(docker images -q)

12. How to remove all the containers from a docker node ?

Ans.docker rm $(docker ps -a -q)

13. How to list all the containers in your docker node ?

Ans. docker ps -a

14. How to list all the images in your system ?

Ans. docker images

15. Can we use the container in pause state ?

Ans. No

16. What is the command to pause the container ?

Ans. docker pause

17. What is the command to unpause the container ?

Ans. docker unpause

18. Which command will help in completely purging all the images and containers in your system ?

Ans. docker system prune

19. How to remove all unused images from a docker host ?

Ans. docker system prune -a

20. Where is the pause state helpful in docker ?

Ans. When you want to take a snapshot of the filesystem to create a new image.

21. What will you do when docker stop command does not help ?

Ans. I will most probably kill the container by using docker kill command.

22. What is the default value of blkio.weight cgroup attribute ?

Ans. 500

23. What is the option used to limit the IO read per sec from a device ?

Ans. --device-read-iops

24. What is the option used to limit the IO write per sec to a device ?

Ans. --device-write-iops

25. How to check out of memory error in docker node ?

Ans. docker events

26. Which command can be used to view docker process tree ?

Ans. pstree

27. Which process is used to map the networks ports between containers and docker nodes ?

Ans. Docker-Proxy Process

28. Which other tool can be used to get into docker container from server itself ?

Ans. nsenter

29. What is command to get into docker running container ?

Ans. docker exec

30. Which command is used to debug the docker container ?

Ans. docker inspect

31. What is the similar command in docker for Linux tail -f command to check the logs ?

Ans. docker logs -f

32. What is the default configuration file for dockerd server ?

Ans. /etc/docker/daemon.json

33. How to turn off the docker logging ?

Ans. By using --log-driver=none switch

34. Which docker environment variable usually contains docker hostname of a Server ?

Ans. $DOCKER_HOST

35. Which command used for inspecting virtual network in a docker ?

Ans. docker network ls

36. Which command is used for checking the network connected by docker container ?

Ans. docker inspect network

37. Which command is used for checking the history of Docker Images ?

Ans. docker history

38. Where does all the containers ID usually resides ?

Ans. /var/lib/docker/containers

39. Which file saves the docker networking configuration ?

Ans. hostconfig.json

40. How to check all the processes running inside a container ?

Ans. docker top <container_id>

41. What is the common debugging tool you can use for debugging docker processes ?

Ans. strace -p <PID>

42. How to run any specific commands when container initializes itself ?

Ans. By using ENTRYPOINT Keyword

43. How can you add any files to a container ?

Ans. By using ADD <source_location> <container_destination_location>

44. What are the few commands used in Dockerfile ?

Ans. FROM,ADD,RUN,CMD,ENTRYPOINT and ENV

45. How to run any commands inside a container ?

Ans. By using RUN <commands_to_run>

46. How to run any command at the start of the container ?

Ans. By using CMD <commands_to_be_run>

47. How can you set any environment variable inside a docker container ?

Ans. By using ENV <variable_name> <value>

48. What is the command to copy the files inside a container ?

Ans. docker cp

49. Which tool can be used for multi-container docker applications ?

Ans. docker-compose

50. Which tool can be used to create and start all services through a YAML file configuration ?

Ans. docker-compose

 

Also Read: Docker: Up and Running

Leave a Comment