65+ Docker Interview Questions For Landing A DevOps Job

Docker is a recent piece of technology that's sweeping the devops world. There's many use cases for Docker. Some of which are designed around the management of on-prem and multiple server environments. Some are around the implementation of regional server setups and general speed optimization. In general, Docker has made a massive impact on our server ops opportunities. Below are some of the best Docker interview questions and answers that will get you prepared for your future job interview. If you have any other questions that you'd like to see listed here, please feel free to reach out to me and they will be added.

Docker Interview Questions & Answers

1. In your opinion, what makes Docker different from other container technology solutions?

Answer: Interviewees will answer this according to their own personal experiences and opinions, but look for a few key notes. A good basic answer will include mentioning the basics about how Docker containers are easy to use with a Cloud, how it allows more apps to run on the same machine compared to other solutions, etc. A great answer will include mentioning how container technologies as a whole, not just Docker in particular, have impacted productivity in application development.

2. Describe host dependent sharing.

Answer: When the same host location is mounted by several containers’ bind volume.

3. True or False. There is a substantial difference between a registry and a repository in Docker.

Answer: True. The Docker registry is a simple service for hosting and moving around images. The Docker repository is a group of Docker images that are related.

4. True or False. Up, Run, and State are all the same command.

Answer: False. upstarts or restarts the services in docker-compose.yml. The yml file. The run command is for running expedient tasks. The start command is only used for restarting containers that were created and stopped.

5. Would it be considered poor or good practice to split different components into separate containers?

Answer: Good practice. This will allow you a bit more flexibility when allowing multiple applications to run on a single server.

6. True or False. Docker works at its best when there are varied processes and tools used.

Answer: False. Docker works at its best when there are consistent processes and tools available. Using multiple tools in Docker can cause more problem than solve them.

7. Is it wise and worthwhile to try implementing containerization for previously created multi-toolsets?

Answer: If time and money has been put into building a CI/CD pipeline, implementing Docker or containerizing legacy application may not be worth the amount of time and work required.

8. Which would be considered to be lighter weight. Docker or Hypervisors?

Answer: Docker is lighter and better structured when it comes to the use of resources. This is because the underlying host kernel is used in favor or creating a hypervisor.

9. What would be considered the source of the Docker container?

Answer: The Docker Image.

10. Name a handful of critical decisions that would need to be made when running Docker for production purposes.

Answer: Which process should be used to build Docker image files for better image management? Which Cloud provider should be selected? What security options should be considered for network access and security patching? Once a move is made from one container service to multiple containers within any number of hosts, what tools will be used for load balancing across these containers and hosts? The configurations for Docker Compose will change quite a bit between development and production, so what will the deployment process look like? Once the amount of containers start growing and the management overhead involved in registering them for app consumption grows with them, what tools will be used to manage this process? Will distributed logging be used for multiple log servers? What monitoring strategy will be implemented?

Note. Look for answers that show a broader knowledge of development outside of Docker and a focus on future-planning and crisis aversion.

11. Briefly summarize containers and why they are innovative and useful for development.

Answer: Containers, at a basic level, are used to keep apps secluded from the entire host system that they will be running on. This is useful because developers will be able to package an application with everything it needs, from libraries to other files, and ship it as a single package. Containers make it substantially easier to provide consistency, speedy production, and replicability in a project.

12. What Docker feature provides a centralized place for workflow automation throughout the development pipeline? Describe this feature in more detail.

Answer: The Docker Hub. This feature is a cloud-based service that allows for the registering and linking to repositories of code, building and testing images, and manually storing pushed images.

13. Who do you believe Docker is developed for?

Answer: Docker as a tool benefits developers, system administrators, and operations staff.

14. Name five container option alternatives to Docker that you know of.

Answer: CoreOS rkt, LXC Linux Containers, Mesos Containerizer, containerd, OpenVZ.

15. What is the term for a repository that allows you to download and use containers?

Answer: The Docker Hub.

16. True or False. Docker is an originally Google-designed open source container cluster manager used for automating scaling, app operations, and deployment.

Answer: False. This is known as Kubernetes (k8s).

17. Is it possible to run several copies of a Compose file in the same host?

Answer: Yes. To do so, set a custom name for the project with the COMPOSE_PROJECT_NAME environment variable.

18. Would it be preferable to include a code with a volume or COPY/ADD?

Answer: COPY/ADD is preferable By adding the code to an image using these directives in a Dockerfile, you can relocate the code with the Docker image.

19. Name five unique Docker commands.

Answer: docker image history my_image
docker image rm $(docker images -a -q)
docker system prune -a --volumes
docker container rm $(docker ps -a -q)
docker container run -it my_image my_command

20. What is an immutable image?

Answer: An immutable image is an image that includes that source code and has all the requirements needed to run through the application. Using immutable images is advantageous because they are more portable, make it easier to perform A/B testing and rollback, and can easily change runtime dependencies.

21. What would cause services to lag or fully stop?

Answer: Stop attempts are used to stop a container by releasing a SIGTERM (a.k.a. a blockable program termination signal). After ten seconds of timeout, a SIGKILL (a.k.a. a fatal program termination signal) is deployed to force kill the container. If one experiences the timeout, it means that means that the containers are not shutting down after receiving the SIGTERM signal.

22. How can this process issue be solved?

Answer: Use CMD’s JSON form plus ENTRYPOINT in the Dockerfile. Avoid using the string form because it forces Docker to run the processes with bash, which handles signals improperly. Modify the app that is running to add a SIGTERM signal handler. Set the stop_signal to a signal which the application knows how to handle. If modifying the app isn’t possible, wrap the application in a light init system that can handle SIGTERM correctly.

23. What are the three networks that can be listed through the Docker network command?

Answer: None, Host, and Bridge (docker0).

24. True or False. Docker Flow is a tool for running Docker applications with multiple containers.

Answer: False. This would be the Docker Compose tool.

25. When it comes to dockerized apps stored in the git repo, what would the deploy process involve?

Answer: Depending on the production environment, the process would involve different things. These include building applications with the docker build through the code directory, testing out an image, swapping ports in a HyperText Transfer Protocol (http) proxy, stopping the old container, etc.

26. Describe the main differences between virtualization and containerization.

Answer: Virtualization involves creating a virtual machine, installing an operating systems inside of it, then deploying the application. Containerization with Docker only involves deploying the application within Docker without the need for creating an operating system layer.

27. Describe the process behind Docker Swarm and its ultimate purpose.

Answer: Docker Swarm is essentially just Docker’s native clustering. Docker Swarm can turn multiple Docker hosts into one uniform virtual host. Tools that already can communicate with an unobtrusive Docker program (a.k.a. daemon) can use Docker Swarm to scale to various hosts.

28. Name six tools that are supported by Docker Swarm.

Answer: Dokku, Mesosphere DC/OS, Jenkins, Docker Compose, AKS, Docker Machine

29. How can Swarm be made to work with TLS?

Answer: Verify that all servers can be retrieved through SSH and have correct DNS names. Allow Manager and Nodes to communicate by opening their ports. Do the same for Client and Manager. Create a CA Server (a.k.a. Certificate Authority Server). Create, sign, and install Keys. Edit the DOCKER_OPTS line so it can use the installed keys. Start the Cluster and Swarm Manager and verify results.

30. In the current market, Docker makes up around 83% of application containers. While that is definitely a substantial number, it’s still down from 99% in 2017. If our project decided to look for alternative solutions to Docker or other container runtime environments, what would you suggest we look for?

Answer: Interviewees will likely provide diverse answers according to their own personal knowledge, but look for a few key responses. First, look for genuine enthusiasm involving alternative methods to Docker. While a particular developer interviewee may have substantial knowledge and experience in Docker, if they have additional knowledge in up-and-coming environments and solutions, they could be a valuable asset for in the event of innovative project changes.

31. When comparing Docker and Kubernetes, what would you say are the biggest differences between them? Should both be used together?

Answer: Docker is particularly useful for building and deploying containers. Kubernetes is useful for managing containers. Docker Swarm does have a native container management tool that is helpful and gets the job done, but using Docker and Kubernetes together could have beneficial results as well. Docker Swarm runs at a much faster pace, provides documentation for every piece of information in the Swarm, allows for easy and quick configuration, ensures application isolation, and offers version control as well as component reusability. Unfortunately Docker Swarm is very much dependant on the platform and doesn’t allow for storage options or decent monitoring. Kubernetes, on the other hand, provides great declarative configuration and has great storage volume. Using the two together (along with Swarm) could provide a perfect balance if the developers at hand know how to properly navigate them both as separate entities and as one solution.

32. True or False. Docker images are typically stored in registry.hub.docker.com.

Answer: True. Images are often stored in the Docker registry under this particular directory because they can become very large in size.

33. True or False. Docker containers hold the target application and all of the dependencies it has and does not share the kernel with outside containers.

Answer: False. Docker containers share the kernel with other containers in the system and run them as standalone processes in the host operating system.

34. True or False. Unless explicitly saved, all the data that was written since the last save will be automatically deleted.

Answer: False. Docker containers automatically saves data that is processed and is written to the disk immediately. The only way to remove data in the container’s file system is to explicitly delete it.

35. What Docker command must be used to inspect recent edits on a particular container’s file system?

Answer: diff

36. Docker provides a lot of benefits to application development, but how does it simplify the process of application creation specifically?

Answer: By providing a particularly very high-level Application Programming Interface (API) to run processes in complete isolation on the server.

37. True or False. When a single container is deleted, the data volume it contained is deleted as well.

Answer: False. The data volume will remain unless explicitly removed.

38. What Docker command must be used to create an entirely new image from one container’s changes?

Answer: commit

39. Where is the most practical place to keep Docker’s directory structure well organized for a particularly large project?

Answer: /containers/web/server1/ws.cid containers/web/server3/ws.cid

40. Describe what orphaned volumes are within Docker.

Answer: Orphaned volumes are data volumes that remain after the container that housed the data has been deleted. They are relatively easy to remove once located.

41. What Docker command must be used to show the current Docker version’s information and details?

Answer: version

42. True or False. There is a default CPU limit that is automatically set for a single container in Docker. This limit is 60%.

Answer: False. There are no default limits for CPU consumption from containers and they can definitely use 100% of the CPU. However, this is adjustable per container.

43. What Docker command must be used to kill a currently active or running container?

Answer: kill

44. True or False. It is possible to create multiple containers within Docker that do not have their own specific parameter identification (PID) namespace.

Answer: True.

45. How can one make Docker support different user namespaces?

Answer: By mapping the root user in a particular container to a user that is not uid-0 and is outside of the original container. Docker does not support user namespaces by default, but this adjustment is fairly easy to do.

46. What Docker command must be used to create an entirely new container within the system?

Answer: create

47. Is it necessary to manage the order of starting containers? If so, why is it necessary?

Answer: Yes. If linked containers are part of the application, there is a dependency occurring between them. Management will be necessary to avoid errors.

48. Name the current Docker version.

Answer: As of March 2019, the current Docker version is 18.09. Note. This is worth asking to see how adept a developer is at staying on top of software and application versions, which will be useful in the case of application errors and management problems.

49. What Docker command must be used to attach a task to a currently active or running container?

Answer: attach

50. What major features in Docker help to build environment agnostic systems?

Answer: Read-only file systems, volumes, and environment variable injection.

51. What Docker command must be used to load an image from the standard input (STDIN)?

Answer: load

52. True or False. Instruction is a Dockerfile are case sensitive unless explicitly changed within the Docker software settings.

Answer: False. Docker instructions and code are not case sensitive and the case sensitivity cannot be changed. However, intentionally using uppercase letters is usually used in order to distinguish them from arguments with ease.

53. True or False. There are only two main states that a single Docker container can be in. Those are Running and Paused.

Answer: False. There are actually four main states that a Docker container can be in. These include Running, Exited, Paused, and Restart.

54. What Docker command must be used to show the entire history of a particular image?

Answer: History.

55. When more than a single command instruction is added to a Docker file, what occurs?

Answer: The last command will be the only one to actually work. Docker can only read one command at a time.

56. Is it possible to delete or remove a container in Docker that is currently paused? If so, what code is needed?

Answer: No. Containers must be fully stopped before edits can be done. However, if the container is stopped properly, the command docker rm can be used to delete it completely.

57. What Docker command must be used to build an entire image from one Docker file?

Answer: Build.

58. How long did it take for you to fluently learn how to use Docker for application development?

Answer: This will obviously vary from interviewee to interviewee, but take note of developers that were experienced in many other platforms before Docker. Their answers will range between four and sixteen hours of experimentation.

59. True or False. Docker containers cannot automatically restart themselves without the explicit command of the developer.

Answer: True. At default, the command –restart is flagged to not restart unless changed manually.

60. If you need to return information, particularly low-level information on a single container or new image, what Docker command must be used to do so?

Answer: inspect

61. What commands can be used to remove containers in Docker? Of those listed, which is the preferred code to do so?

Answer: docker rm -f and docker stop with docker rm can be used to remove containers. The former is not recommended. The latter is definitely preferred because it will send the SIG_HUP signal to the correct recipients and give them a better timeline to perform the necessary tasks, such as finalization and clean-up.

62. What Docker command must be used to display and research information on the entire system?

Answer: info

63. When you perform docker pull, where do the Docker images get transferred to?

Answer: It depends on the operating system. For Linux, the subdirectory is usually /var/lib/docker. However, running docker inspect NAME|ID in the command line can reveal where it actually is located in the system. Note. This is a good question to ask interviewees because it can shine a light on if they actually experiment with Docker and navigate its more niche solutions.

64. What Docker command must be used to launch Docker via daemon?

Answer: dockerd

65. What is the best way to link containers, is there is a way to?

Answer: One can utilize network port mapping to link containers. This is typically the easiest way to do so. You can also change the - -link flag.

66. Name the platforms that Docker is currently able to run on.

Answer: Linux and Cloud are the only platforms capable of running Docker. They include Ubuntu, CRUX, Fedora, openSUSE, RHEL, ArchLinux,CentOS, Gentoo, Rackspace, Amazon EC2, Google CE, and Microsoft Azure. It is worth noting that Docker cannot run on Windows PC or Apple devices. However, Docker containers can run natively on Windows with a Windows server younger than 2016. Windows Nano Server can be used to run lightweight operating systems inside containers.

67. Why did you decide to become a Docker developer?

Answer: Is this not the most basic question you could ask in an interview? Still, in the realm of hiring developers for your team, it’s a necessary question to ask. Docker is a complex but very beneficial solution to application design. Developers that are passionate about seeing their Docker projects through but are also prepared to learn about new technology solutions that will inevitably pop up could be vital assets for your project.

author: patrick algrim
About the author

Patrick Algrim is an experienced executive who has spent a number of years in Silicon Valley hiring and coaching some of the world’s most valuable technology teams. Patrick has been a source for Human Resources and career related insights for Forbes, Glassdoor, Entrepreneur, Recruiter.com, SparkHire, and many more.


Help us by spreading the word