Docker Certification Practice Questions – Dockerfile

docker certification

Docker allows applications to run securely while being isolated in a container, packaged with all its dependencies and libraries. It has become extremely popular virtualization technology of recent times. Thus, it makes it much more important to learn this technology and complement your developer’s experience as it not only enhances your productivity but also help you in your career from an overall perspective. Read this post in relation to why you should consider adopting docker sooner than later.

In this post, you will take a practice test and learn the related notes in relation to building Docker image using Dockerfile. This and several other practice tests which will be published in the coming days will help you test your knowledge in relation to Docker fundamentals in general. It would help you pass the Docker Certified Associate certification exams. It would also be useful in taking up Docker professional interview in a confident manner. This practice test can also be seen as interview questions and answers.

Practice Test – Docker Image creation

[wp_quiz id=”6696″]

Revision Notes – Dockerfile

  • It is recommended to start with an empty directory as context and keep the Dockerfile in that directory along with files which are required for building the image.
  • The following is done as part of the docker build command:
    • The context (files from current directory) is sent to Docker daemon
    • Dockerfile syntax is parsed and checked for validity
    • Each instruction in Dockerfile is executed resulting in creation of new images as layers
    • After successful build, an image ID is returned by Docker daemon
    • The context is cleared/deleted/cleaned up.
  • A Dockerfile must start with FROM instruction, if not ARG
  • RUN instruction actually runs a command and commits the result
  • CMD instruction does not execute anything at build time of an image. It should be used as a way of defining default arguments for an ENTRYPOINT instruction or for executing an ad-hoc command in a container.

Interview Questions

  • Why is it recommended to start building the docker image with an empty directory consisting of docker file and relevant files required for building the image?
  • Is this OK to use more than one FROM in a Dockerfile? Why would one want to have more than one FROM in the same Dockerfile?
  • What is the difference between RUN and CMD command used in the Dockerfile?
  • How can CMD and ENTRYPOINT command be used together?

Further Reading / Reference

Summary

In this post, you learned about fundamentals in relation to building an image using Dockerfile and also went through related practice questions which can prove to be helpful with your Docker certification.

Did you find this article useful? Do you have any questions or suggestions about this article in relation to image creation using Dockerfile? Leave a comment and ask your questions and I shall do my best to address your queries.

Ajitesh Kumar

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.
Posted in certifications, Dockers, Interview questions. Tagged with , , .

One Response