Docker Interview Questions and Answers
Question - 71 : - How have you used Docker in your previous position?
Answer - 71 : -
Explain how you have used Docker to help rapid deployment. Explain how you have scripted Docker and used it with other tools like Puppet, Chef or Jenkins. If you have no past practical experience in Docker and instead have experience with other tools in a similar space, be honest and explain the same. In this case, it makes sense if you can compare other tools to Docker in terms of functionality.
Question - 72 : - Can I use JSON instead of YAML for my compose file in Docker?
Answer - 72 : -
You can use JSON instead of YAML for your compose file, to use JSON file with compose, specify the JSON filename to use, for eg:
$ docker-compose -f docker-compose.json up
Question - 73 : - How is Docker different from other containerization methods?
Answer - 73 : -
Docker containers are very easy to deploy in any cloud platform. It can get more applications running on the same hardware when compared to other technologies, it makes it easy for developers to quickly create, ready-to-run containerized applications and it makes managing and deploying applications much easier. You can even share containers with your applications.
Question - 74 : - Where all do you think Docker is being used?
Answer - 74 : -
When asked such a question, respond by talking about applications of Docker. Docker is being used in the following areas:
- Simplifying configuration: Docker lets you put your environment and configuration into code and deploy it.
- Code Pipeline Management: There are different systems used for development and production. As the code travels from development to testing to production, it goes through a difference in the environment. Docker helps in maintaining the code pipeline consistency.
- Developer Productivity: Using Docker for development gives us two things – We’re closer to production and development environment is built faster.
- Application Isolation: As containers are applications wrapped together with all dependencies, your apps are isolated. They can work by themselves on any hardware that supports Docker.
- Debugging Capabilities: Docker supports various debugging tools that are not specific to containers but work well with containers.
- Multi-tenancy: Docker lets you have multi-tenant applications avoiding redundancy in your codes and deployments.
- Rapid Deployment: Docker eliminates the need to boost an entire OS from scratch, reducing the deployment time.
Question - 75 : - Will you lose your data, when a docker container exists?
Answer - 75 : -
No, you won’t lose any data when Docker container exits. Any data that your application writes to the container gets preserved on the disk until you explicitly delete the container. The file system for the container persists even after the container halts.
Question - 76 : - Do you know why docker system prune is used? What does it do?
Answer - 76 : -
$ docker system prune
The above command is used to remove all the stopped containers, all the networks that are not used, all dangling images and all build caches. It’s one of the most useful docker commands.
Question - 77 : - How to build a Dockerfile?
Answer - 77 : -
Once you’ve written a Dockerfile, you need to build it to create an image with those specifications. Use the following command to build a Dockerfile:
The next question would be when do you use “.dockerfile_name” and when to use the entire path?
Use “.dockerfile_name” when the dockerfile exits in the same file directory and you use the entire path if it lives somewhere else.
Question - 78 : - How to delete an image from the local storage system?
Answer - 78 : -
The following command lets you delete an image from the local system:
$ docker rmi
Question - 79 : - How to delete a stopped container?
Answer - 79 : -
Use the following command to delete a stopped container:
$ docker rm
Question - 80 : - Once you’ve worked with an image, how do you push it to docker hub?
Answer - 80 : -
$ docker push