meta data for this page

Dockerfile

Build process

Docker process Dockerfile stepping through the instructions. https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache

FROM

ENTRYPOINT

RUN

ADD

https://docs.docker.com/engine/reference/builder/#/add

  • Copy new files, directories or URLs and adds them to filesystem of image
  • All new files and directories are created with a UID and GID of 0.
  • It supports TAR archive (gzip, bzip2 compressed)

COPY

https://docs.docker.com/engine/reference/builder/#/copy

  • Copy new files or directories to the filesystem of container (not adding to image)
  • All new files and directories are created with a UID and GID of 0.
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 won't have to add another layer in your image.
RUN mkdir -p /usr/src/things \
&& curl -SL http://example.com/big.tar.gz \
| tar -xJC /usr/src/things \
&& make -C /usr/src/things all

For other items (files, directories) that do not require ADD’s tar auto-extraction capability, you should always use COPY.“

From source code comment:

Same as 'ADD' but without the tar and remote url handling.

From Docker docs:

ADD or COPY

Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the >container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction >into the image, as in ADD rootfs.tar.xz /.

EXPOSE

VOLUME