ScanSkill

ADD

The instruction ADD copies content, files, directories, or remote URL files from source and adds them to the file system of docker image at destination path.

Syntax

ADD [--chown=<user>:<group>] <src>... <dest>
ADD [--chown=<user>:<group>] ["<src>",... "<dest>"]

Note: Here, --chown feature is only for Linux containers, and it will not work for Windows.

Example

  • To add all files from project root to destination file system path of image:
ADD . /path/to/image/filesystem/
  • To add all files starting with “clou”:
ADD clou* /cloudyfoxdir/
  • This ? will replace any single character like cloudy.txt:
ADD cloud?.txt /cloudyfoxdir/

Here, the destination is an absolute path or relative path to WORKDIR. Below is an example of a relative path and this will add cloudy.txt file to <WORKDIR>/relativeDir/:

ADD cloudy.txt relativeDir/

Similarly, the following example uses an absolute path and adds cloudy.txt file to /absoluteDir/:

ADD cloudy.txt /absoluteDir/