Dockerfile is a text file that contains instructions to automate the creation of a Docker image. It allows users to build images automatically by specifying commands in a Dockerfile. The build context refers to the files at the specified file path or URL used during the build process. A Dockerfile begins with a FROM instruction and can include instructions like LABEL, EXPOSE, WORKDIR, ADD, COPY, USER, ENV, RUN, ENTRYPOINT and CMD to customize the image.