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.

Table of Contents

Practice Test – Docker Image creation

Docker build is run by _________

Correct! Wrong!

Docker builds the image using the context which is _________

Correct! Wrong!

It is OK to use root directory such as / as the PATH for building the docker image

Correct! Wrong!

Which of the following option is used to specify a repository and a tag for saving the image after the build is done

Correct! Wrong!

Docker image can be saved in multiple repositories after the build is done

Correct! Wrong!

Docker reuse intermediate images for accelerating the docker build process

Correct! Wrong!

A Dockerfile can start with any command

Correct! Wrong!

A docker file must be named as Dockerfile

Correct! Wrong!

FROM keyword can only appear once at the start of the Dockerfile

Correct! Wrong!

It is OK to have more than one RUN instruction in the Docker file

Correct! Wrong!

Both RUN and CMD instruction can be used interchangeably in the Dockerfile as they do the similar thing

Correct! Wrong!

It is OK to have more than one CMD instruction in the Docker file

Correct! Wrong!

Which of the following instruction can primarily be used for defining default arguments for an ENTRYPOINT command

Correct! Wrong!

Which of the following instruction can be used to inform Docker that containers listen on specific ports?

Correct! Wrong!

Which of the following instruction actually runs a command and commits the result during the time of building the image

Correct! Wrong!

Which of the following can be used to define what command gets executed when running a container

Correct! Wrong!

Which of the following instructions can be used to specify variables that are available to the RUN instruction

Correct! Wrong!

ARG variables are persisted into the built image as like the ENV variables

Correct! Wrong!

Docker certification practice questions - Dockerfile
You did extremely well!!
You did reasonably well!!
Better luck next time!!

Share your Results:

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
Follow me

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. For latest updates and blogs, follow us on Twitter. 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. Check out my other blog, Revive-n-Thrive.com
Posted in certifications, Dockers, Interview questions. Tagged with , , .

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *