Dockerfile Cheat Sheet

From WikiOD

Here is the cheatsheat of Dockerfile and basic guide on how to use Dockerfile

Reference[edit | edit source]

{: .-three-column}

Inheritance[edit | edit source]

FROM ruby:2.2.2

Variables[edit | edit source]

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
ARG APP_HOME=""
RUN mkdir $APP_HOME

Initialization[edit | edit source]

RUN bundle install
WORKDIR /myapp
VOLUME ["/data"]
# Specification for mount point
ADD file.xyz /file.xyz
COPY --chown=user:group host_file.xyz /path/container_file.xyz

Onbuild[edit | edit source]

ONBUILD RUN bundle install
# when used with another file

Commands[edit | edit source]

EXPOSE 5900
CMD    ["bundle", "exec", "rails", "server"]

Entrypoint[edit | edit source]

ENTRYPOINT ["executable", "param1", "param2"]
ENTRYPOINT command param1 param2

Configures a container that will run as an executable.

ENTRYPOINT exec top -b

This will use shell processing to substitute shell variables, and will ignore any CMD or docker run command line arguments.

Metadata[edit | edit source]

LABEL version="1.0"
LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
LABEL description="This text illustrates \
that label-values can span multiple lines."

See also[edit | edit source]

{: .-one-column}

Credit:rstacruz