What is Dockerfile ?
Docker file is a text file, that contains set of instructions to create a docker image.
Simplified definitions for Docker file instructions:
FROM — Defines a base image, it can be pulled from docker hub
(for example- if we want to create a java script application with node as backend then we need to have node as a base image, so it can run node application.)
RUN — Executes command in a new image layer( we can have multiple run commands )
CMD — Command to be executed when running a container( It is asked to have one CMD command, If a Dockerfile has multiple CMDs, it only applies the instructions from the last one.
ENTRYPOINT — Define a container’s executable (You cannot override and ENTRYPOINT when starting a container unless you add the — entrypoint flag.)
WORKDIR — Defines the working directory for subsequent instructions in the Docker file.
COPY — Copy new files or directories into the filesystem of the container.
ADD — It is more feature-rich version of the COPY instruction. COPY is preferred over ADD. Major difference b/w ADD and COPY is that ADD allows you to copy from URL that is the source can be URL but in COPY it can only have local ones.
VOLUME — It defines which directory in an image should be treated as a volume. The volume will be given a random name which can be found using docker inspect command.
EXPOSE — Informs container runtime that the container listens on the specified network ports at runtime
ENV — Sets environment variables inside the image