Skip to content

Instantly share code, notes, and snippets.

@jrmsamson
Last active September 4, 2018 19:54
Show Gist options
  • Save jrmsamson/47db084071fadf62dc63d42ebfbee217 to your computer and use it in GitHub Desktop.
Save jrmsamson/47db084071fadf62dc63d42ebfbee217 to your computer and use it in GitHub Desktop.
# FROM instructions support variables that are declared by any ARG instructions
# Docker has a set of predefined ARG variables that you can use without a
# HTTP_PROXY, HTTPS_PROXY, FTP_PROXY, NO_PROXY
ARG CODE_VERSION=latest
# Initializes a new build stage and sets the Base Image for subsequent instructions
FROM ImageName:${CODE_VERSION}
# RUN has 2 forms:
# - RUN <command> (shell form)
# - RUN ["executable", "param1", "param2"] (exec form)
RUN echo ${CODE_VERSION}
# The CMD instruction has three forms:
# - CMD ["executable","param1","param2"]
# - CMD ["param1","param2"]
# - CMD command param1 param2
CMD ["/usr/bin/wc","--help"]
#The ENV instruction sets the environment variable <key> to the value <value>
ENV <key> <value>
#Set the working directory for any RUN, CMD, ENTRYPOINT,
#COPY AND ADD instruccions that follow it in the Dockerfile
WORKDIR /path/to/workdir
# Copy file from the host to the container
COPY file1.txt /opt/file1.txt
# Informs Docker that the container listens on the specified network ports at runtime
EXPOSE 80
# Allows the default shell used for the shell form of commands to be overridden
SHELL ["/bin/sh", "-c"]
HEALTHCHECK --interval=30s --timeout=3s --retries=3 --start-period=15s \
CMD curl -f http://localhost/ || exit 1
# ENTRYPOINT has two forms:
# - ENTRYPOINT ["executable", "param1", "param2"]
# - ENTRYPOINT command param1 param2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment