Image Creation, Management, and Registry (20%) Flashcards
Image Creation, Management, and Registry (20%)
Which instruction sets the base image for the subsequent builds in the Dokcerfile?
FROM
No instruction can precede FROM in the Dockerfile. Is this statement correct?
No. ARG is the only instruction can precede FROM
What are the two forms for the RUN instruction?
shell form: RUN
exec form: RUN [“executable”, “param1”, “param2”]
What does the RUN instruction do in the Dockerfile?
The RUN instruction will execute any commands in a new layer on top of the current image and commit the results.
The RUN command normally utilizes cache from the previous build. Which flag should you specify for the build not to use cache?
–no-cache
docker build –no-cache .
Is there any other instruction that can invalidate the cache?
Yes. ADD
How many forms that CMD instruction has?
CMD [“executable”,”param1”,”param2”] (exec form, this is the preferred form)
CMD [“param1”,”param2”] (as default parameters to ENTRYPOINT)
CMD command param1 param2 (shell form)
If CMD instruction provides default arguments for the ENTRYPOINT instruction, both should be specified in JSON format. Is this statement correct?
Yes
What is the purpose of the CMD instruction in the Dockerfile?
The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.
How to make your container execute the same executable every time?
use ENTRYPOINT in combination with CMD
What is the purpose of the LABEL instruction in the Dockerfile?
It adds metadata to the Image
How to check the labels for the current image?
docker inspect // Under Labels section
The EXPOSE instruction actually publish the port. Is this statement correct?
No. It serves as a type of documentation between the image publisher and image consumer
What should you do to actually publish the ports?
use -p flag when running a container
What is the purpose of the ENV instruction in the Dockerfile?
ENV an ENV instruction sets the enviroment value to the key and it is available for the subsequent build steps and in the running container as well.
How to change the environment variables when running containers?
docker run –env =
What is the difference between ADD and COPY instructions?
ADD [–chown=:] … The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the path .COPY [–chown=:] … The COPY instruction copies new files or directories from and adds them to the filesystem of the container at the path .
What is ENTRYPOINT instruction in the Dockerfile?
An ENTRYPOINT allows you to configure a container that will run as an executable.Command line arguments to docker run will be appended after all elements in an exec form ENTRYPOINT, and will override all elements specified using CMD.
How can you override the ENTRYPOINT instruction?
docker run –entrypoint
What is the VOLUME instruction in the Dockerfile?
The VOLUME instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers.
What initializes the newly created Volume?
docker run -v
What is the USER instruction in the Dockerfile?
The USER instruction sets the user name (or UID) and optionally the user group (or GID) to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.
What is the WORKDIR instruction in the Dockerfile?
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile.
You have specified multiple WORKDIR instructions in the Dockerfile what is the result WORKDIR?
WORKDIR /a WORKDIR b WORKDIR c RUN pwd result: /a/b/c
What is the ARG instruction in the Dockerfile?
ARG [=]The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the –build-arg = flag.
What is the ONBUILD instruction in the Dockerfile?
The ONBUILD instruction adds to the image a trigger instruction to be executed at a later time, when the image is used as the base for another build.