If you are looking to crack your DevOps engineer interview, docker is one of the important topics that you should prepare. In this guide, understand the docker interview questions for DevOps that you should know.
Let’s go!
Table of Content
Q1. What is Docker ?
Answer: Docker is lightweight containerized technology. It allows you to automate deployment in portable containers which is built from docker images.
Q2. What is Docker Engine.
Answer: Docker Engine is an server where docker is installed . Docker Client and server remains on the same server or remote host. Clients can connect with server using CLI or RESTful API’s.
Q3. What is use of Dockerfile and what are common instructions used in docker file?
Answer: We can either pull docker image and use it directly to build our apps or we can use it and on top of it we can create one more layer according to the need that’s where Dockerfile comes in play. With Docker file you can design the image accordingly. Some common instructions are FROM, LABEL, RUN , CMD
Q4. What are States of Docker Containers ?
Answer: Running , Exited , Restarting and Paused.
Q5. What is DockerHUB ?
Answer: Dockerhub is a cloud based registry for docker images . You can either pull or push your images in DockerHub.
Q6. Where are Docker Volumes stored ?
Answer: Docker Volumes are stored in /var/lib/docker/volumes.
Q7.Write a Dockerfile to Create and Copy a directory and built using Python Module ?
Answer:
FROM Python:3.0
WORKDIR /app
COPY . /app
Q8. What is the medium of communication between docker client and server?
Answer: Communication between docker client and server is taken care by REST API , socker.IO and TCP Protocol.
Q9. How to start Docker container and create it ?
Answer: Below command will create the container as well as run the container. Ideally just to create container you use docker container create “Container_name”
docker run -i -t centos:6
Q10.What is difference between EXPOSE PORT and PUBLISH Port ?
Answer: Expose Port means you just exposes it locally i.e to container only . Publish Port means you are allowing from outside World.
Q11. How can you publish Port i.e Map Host to container port ? Provide an example with command
Answer:
Here p is mapping between Host and container and -d is dettached mode i.e container runs in background and you just see container ID displayed on
docker container run -d -p 80:80 nginx
Q12. How do you mount a volume in docker ?
Answer:
docker container run -d --name "My container" --mount source="vol1",target=/app nginx
Q13. How Can you run multiple containers in single service ?
Answer: We can achieve this by using docker swarm or docker compose. Docker compose uses YAML formatted files.
Q14. Where do you configure logging driver in docker?
Answer: We can do that in file daemon.jason.file.
Q15. How can we go inside the container ?
Answer:
docker exec -it "Container_ID" /bin/bash
Q16. How can you scale your Docker containers?
Answer: By using Docker compose command.
docker-compose --file scale.yml scale myservice=5
Q17. Describe the Workflow from Docker file to Container execution ?
Answer: Docker file ➤ Docker Build ➤ Docker Image (or Pull from Registry) ➤Docker run -it ➤ Docker Container ➤Docker exec -it ➤Bash
Q18. How to monitor your docker in production ?
Answer:
docker stats : Get information about CPU , memory and usage etc.
docker events : Check activities of containers such as attach , detach , die, rename , commit etc.
Q19. Is Docker swarm an approach to orchestrate containers ?
Answer: Yes it is one of them and other is kubernetes
Q20. How can you check docker version?
Answer: docker version command which gives you client and server information together.
Q21. How can you tag your Docker Image ?
Answer: Using docker tag command.
docker tag "ImageID" "Repository":tag
Conclusion
In this guide, you learned some of the basic questions around the docker interview questions for DevOps that you should know.
There is some more interview guide published on automateinfra.com; which one did you like the most?