Skip to content

Instantly share code, notes, and snippets.

@scottrbaxter
Created August 14, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottrbaxter/ecac3e7df4f3168bd8a7eaedc007bce8 to your computer and use it in GitHub Desktop.
Save scottrbaxter/ecac3e7df4f3168bd8a7eaedc007bce8 to your computer and use it in GitHub Desktop.
# docker build info
# parts to a Dockerfile for building local "image"
Command # Description
ADD # Copies a file from the host system onto the container
CMD # The command that runs when the container starts
ENTRYPOINT # sets the concrete default application that is used every time a container is created using the image
ENV # Sets an environment variable in the new container
EXPOSE # Opens a port for linked containers
FROM # The base image to use in the build. This is mandatory and must be the first command in the file.
MAINTAINER # An optional value for the maintainer of the script
ONBUILD # A command that is triggered when the image in the Dcokerfile is used as a base for another image
RUN # Executes a command and save the result as a new layer
USER # Sets the default user within the container
VOLUME # Creates a shared volume that can be shared among containers or by the host machine
WORKDIR # Set the default working directory for the container
# Once you've created a Dockerfile and added all your instructions, you can use it to build an image using
# docker build -f /path/to/Dockerfile # example
FROM ubuntu:16.04
MAINTAINER User Name "username@example.com"
RUN apt-get update
RUN apt-get install -y git
RUN git clone <repo-path>
RUN echo 'My docker image' > /usr/share/myimage/html/index.html
EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment