DockerFile - Instruction

1 - Instruction

1.1 - FROM

1.2 - LABEL

# Set one or more individual labels
LABEL com.example.version="0.0.1-beta"
LABEL vendor="ACME Incorporated"
LABEL com.example.release-date="2015-02-12"

1.3 - RUN

Tool installation (note: the package are sorted in alphabetical order)

RUN apt-get update && apt-get install -y \
        package-bar \
        package-baz \

More … DockerFile - Run command

1.4 - ARG

Defines argument that can be passed by the build command line

See Dockerfile - ARG instruction (argument)

1.5 - ADD /COPY

  • COPY only supports the basic copying of local files into the container,
  • ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious.

COPY is preferred.

COPY them individually, rather than all at once. This ensures that each step’s build cache is only invalidated (forcing the step to be re-run) if the specifically required files change.

COPY ./apache2.conf /etc/apache2/apache2.conf
COPY ./php.ini /usr/local/etc/php/php.ini

Because image size matters, using ADD to fetch packages from remote URLs is strongly discouraged; you should use curl or wget instead. That way you can delete the files you no longer need after they’ve been extracted and you don’t have to add another layer in your image.

RUN mkdir -p /usr/src/things \
    && curl -SL \
    | tar -xJC /usr/src/things \
    && make -C /usr/src/things all

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap