Skip to content

Instantly share code, notes, and snippets.

@carousel
Last active July 13, 2018 08:20
Show Gist options
  • Save carousel/389d268598608eaa9c38edf54fac6153 to your computer and use it in GitHub Desktop.
Save carousel/389d268598608eaa9c38edf54fac6153 to your computer and use it in GitHub Desktop.
Dockerfile reference with explanation
#.dockerignore
#Sets the Base Image for subsequent instructions.
FROM
#(deprecated - use LABEL instead) Set the Author field of the generated images.
MAINTAINER
#execute any commands in a new layer on top of the current image and commit the results.
RUN
#provide defaults for an executing container.
CMD
#informs Docker that the container listens on the specified network ports at runtime. NOTE: does not actually make ports accessible.
EXPOSE
#sets environment variable.
ENV
#copies new files, directories or remote file to container. Invalidates caches. Avoid ADD and use COPY instead.
ADD
#copies new files or directories to container. Note that this only copies as root, so you have to chown manually regardless of your USER / WORKDIR setting. See https://github.com/moby/moby/issues/30110
COPY
#configures a container that will run as an executable.
ENTRYPOINT
#creates a mount point for externally mounted volumes or other containers.
VOLUME
#sets the user name for following RUN / CMD / ENTRYPOINT commands.
USER
#sets the working directory.
WORKDIR
#defines a build-time variable.
ARG
#adds a trigger instruction when the image is used as the base for another build.
ONBUILD
#sets the system call signal that will be sent to the container to exit.
STOPSIGNAL
#apply key/value metadata to your images, containers, or daemons.
LABEL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment