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
Docker build is run by _________
Docker builds the image using the context which is _________
It is OK to use root directory such as / as the PATH for building the docker image
Which of the following option is used to specify a repository and a tag for saving the image after the build is done
Docker image can be saved in multiple repositories after the build is done
Docker reuse intermediate images for accelerating the docker build process
A Dockerfile can start with any command
A docker file must be named as Dockerfile
FROM keyword can only appear once at the start of the Dockerfile
It is OK to have more than one RUN instruction in the Docker file
Both RUN and CMD instruction can be used interchangeably in the Dockerfile as they do the similar thing
It is OK to have more than one CMD instruction in the Docker file
Which of the following instruction can primarily be used for defining default arguments for an ENTRYPOINT command
Which of the following instruction can be used to inform Docker that containers listen on specific ports?
Which of the following instruction actually runs a command and commits the result during the time of building the image
Which of the following can be used to define what command gets executed when running a container
Which of the following instructions can be used to specify variables that are available to the RUN instruction
ARG variables are persisted into the built image as like the ENV variables
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.
- 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
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.
- Free Datasets for Machine Learning & Deep Learning - February 22, 2021
- Actionable Insights Examples – Turning Data into Action - February 7, 2021
- When to use Deep Learning vs Machine Learning Models? - January 17, 2021