Blame containers-containerfile.5.md

fbcbaa5
% "CONTAINERFILE" "5" "Aug 2021" "" "Container User Manuals"
fbcbaa5
fbcbaa5
# NAME
fbcbaa5
fbcbaa5
Containerfile(Dockerfile) - automate the steps of creating a container image
fbcbaa5
fbcbaa5
# INTRODUCTION
fbcbaa5
fbcbaa5
The **Containerfile** is a configuration file that automates the steps of creating a container image. It is similar to a Makefile. Container engines (Podman, Buildah, Docker) read instructions from the **Containerfile** to automate the steps otherwise performed manually to create an image. To build an image, create a file called **Containerfile**.
fbcbaa5
fbcbaa5
The **Containerfile** describes the steps taken to assemble the image. When the
fbcbaa5
**Containerfile** has been created, call the `buildah bud`, `podman build`, `docker build` command,
fbcbaa5
using the path of context directory that contains **Containerfile** as the argument. Podman and Buildah default to **Containerfile** and will fall back to **Dockerfile**. Docker only will search for **Dockerfile** in the context directory.
fbcbaa5
fbcbaa5
fbcbaa5
**Dockerfile** is an alternate name for the same object.  **Containerfile** and **Dockerfile** support the same syntax.
fbcbaa5
fbcbaa5
# SYNOPSIS
fbcbaa5
fbcbaa5
INSTRUCTION arguments
fbcbaa5
fbcbaa5
For example:
fbcbaa5
fbcbaa5
  FROM image
fbcbaa5
fbcbaa5
# DESCRIPTION
fbcbaa5
fbcbaa5
A Containerfile is a file that automates the steps of creating a container image.
fbcbaa5
A Containerfile is similar to a Makefile.
fbcbaa5
fbcbaa5
# USAGE
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  buildah bud .
fbcbaa5
  podman build .
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- Runs the steps and commits them, building a final image.
fbcbaa5
  The path to the source repository defines where to find the context of the
fbcbaa5
  build.
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  buildah bud -t repository/tag .
fbcbaa5
  podman build -t repository/tag .
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- specifies a repository and tag at which to save the new image if the build
fbcbaa5
  succeeds. The container engine runs the steps one-by-one, committing the result
fbcbaa5
  to a new image if necessary, before finally outputting the ID of the new
fbcbaa5
  image.
fbcbaa5
fbcbaa5
  Container engines re-use intermediate images whenever possible. This significantly
fbcbaa5
  accelerates the *build* process.
fbcbaa5
fbcbaa5
# FORMAT
fbcbaa5
fbcbaa5
  `FROM image`
fbcbaa5
fbcbaa5
  `FROM image:tag`
fbcbaa5
fbcbaa5
  `FROM image@digest`
fbcbaa5
fbcbaa5
  -- The **FROM** instruction sets the base image for subsequent instructions. A
fbcbaa5
  valid Containerfile must have **FROM** as its first instruction. The image can be any
fbcbaa5
  valid image. It is easy to start by pulling an image from the public
fbcbaa5
  repositories.
fbcbaa5
fbcbaa5
  -- **FROM** must be the first non-comment instruction in Containerfile.
fbcbaa5
fbcbaa5
  -- **FROM** may appear multiple times within a single Containerfile in order to create
fbcbaa5
  multiple images. Make a note of the last image ID output by the commit before
fbcbaa5
  each new **FROM** command.
fbcbaa5
fbcbaa5
  -- If no tag is given to the **FROM** instruction, container engines apply the
fbcbaa5
  `latest` tag. If the used tag does not exist, an error is returned.
fbcbaa5
fbcbaa5
  -- If no digest is given to the **FROM** instruction, container engines apply the
fbcbaa5
  `latest` tag. If the used tag does not exist, an error is returned.
fbcbaa5
fbcbaa5
**MAINTAINER**
fbcbaa5
  -- **MAINTAINER** sets the Author field for the generated images.
fbcbaa5
  Useful for providing users with an email or url for support.
fbcbaa5
fbcbaa5
**RUN**
fbcbaa5
  -- **RUN** has two forms:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  # the command is run in a shell - /bin/sh -c
fbcbaa5
  RUN <command>
fbcbaa5
fbcbaa5
  # Executable form
fbcbaa5
  RUN ["executable", "param1", "param2"]
fbcbaa5
  ```
fbcbaa5
fbcbaa5
**RUN Secrets*
fbcbaa5
fbcbaa5
The RUN command has a feature to allow the passing of secret information into the image build. These secrets files can be used during the RUN command but are not committed to the final image. The `RUN` command supports the `--mount` option to identify the secret file. A secret file from the host is mounted into the container while the image is being built.
fbcbaa5
fbcbaa5
Container engines pass secret the secret file into the build using the `--secret` flag.
fbcbaa5
fbcbaa5
**RUN --mount* options:
fbcbaa5
fbcbaa5
- `id` is the identifier to for the secret passed into the `buildah bud --secret` or `podman build --secret`. This identifier is associated with the RUN --mount identifier to use in the Containerfile.
fbcbaa5
fbcbaa5
- `dst`|`target`|`destination` rename the secret file to a specific file in the Containerfile RUN command to use.
fbcbaa5
fbcbaa5
- `type=secret` tells the --mount command that it is mounting in a secret file
fbcbaa5
fbcbaa5
# shows secret from default secret location:
fbcbaa5
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
fbcbaa5
fbcbaa5
# shows secret from custom secret location:
fbcbaa5
RUN --mount=type=secret,id=mysecret,dst=/foobar cat /foobar
fbcbaa5
fbcbaa5
The secret needs to be passed to the build using the --secret flag. The final image built does not container the secret file:
fbcbaa5
fbcbaa5
```
fbcbaa5
 buildah bud --no-cache --secret id=mysecret,src=mysecret.txt .
fbcbaa5
```
fbcbaa5
fbcbaa5
  -- The **RUN** instruction executes any commands in a new layer on top of the current
fbcbaa5
  image and commits the results. The committed image is used for the next step in
fbcbaa5
  Containerfile.
fbcbaa5
fbcbaa5
  -- Layering **RUN** instructions and generating commits conforms to the core
fbcbaa5
  concepts of container engines where commits are cheap and containers can be created from
fbcbaa5
  any point in the history of an image. This is similar to source control.  The
fbcbaa5
  exec form makes it possible to avoid shell string munging. The exec form makes
fbcbaa5
  it possible to **RUN** commands using a base image that does not contain `/bin/sh`.
fbcbaa5
fbcbaa5
  Note that the exec form is parsed as a JSON array, which means that you must
fbcbaa5
  use double-quotes (") around words not single-quotes (').
fbcbaa5
fbcbaa5
**CMD**
fbcbaa5
  -- **CMD** has three forms:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  # Executable form
fbcbaa5
  CMD ["executable", "param1", "param2"]`
fbcbaa5
fbcbaa5
  # Provide default arguments to ENTRYPOINT
fbcbaa5
  CMD ["param1", "param2"]`
fbcbaa5
fbcbaa5
  # the command is run in a shell - /bin/sh -c
fbcbaa5
  CMD command param1 param2
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- There should be only one **CMD** in a Containerfile. If more than one **CMD** is listed, only
fbcbaa5
  the last **CMD** takes effect.
fbcbaa5
  The main purpose of a **CMD** is to provide defaults for an executing container.
fbcbaa5
  These defaults may include an executable, or they can omit the executable. If
fbcbaa5
  they omit the executable, an **ENTRYPOINT** must be specified.
fbcbaa5
  When used in the shell or exec formats, the **CMD** instruction sets the command to
fbcbaa5
  be executed when running the image.
fbcbaa5
  If you use the shell form of the **CMD**, the `<command>` executes in `/bin/sh -c`:
fbcbaa5
fbcbaa5
  Note that the exec form is parsed as a JSON array, which means that you must
fbcbaa5
  use double-quotes (") around words not single-quotes (').
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM ubuntu
fbcbaa5
  CMD echo "This is a test." | wc -
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- If you run **command** without a shell, then you must express the command as a
fbcbaa5
  JSON array and give the full path to the executable. This array form is the
fbcbaa5
  preferred form of **CMD**. All additional parameters must be individually expressed
fbcbaa5
  as strings in the array:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM ubuntu
fbcbaa5
  CMD ["/usr/bin/wc","--help"]
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- To make the container run the same executable every time, use **ENTRYPOINT** in
fbcbaa5
  combination with **CMD**.
fbcbaa5
  If the user specifies arguments to `podman run` or `docker run`, the specified commands
fbcbaa5
  override the default in **CMD**.
fbcbaa5
  Do not confuse **RUN** with **CMD**. **RUN** runs a command and commits the result.
fbcbaa5
  **CMD** executes nothing at build time, but specifies the intended command for
fbcbaa5
  the image.
fbcbaa5
fbcbaa5
**LABEL**
fbcbaa5
  -- `LABEL <key>=<value> [<key>=<value> ...]`or
fbcbaa5
  ```
fbcbaa5
  LABEL <key>[ <value>]
fbcbaa5
  LABEL <key>[ <value>]
fbcbaa5
  ...
fbcbaa5
  ```
fbcbaa5
  The **LABEL** instruction adds metadata to an image. A **LABEL** is a
fbcbaa5
  key-value pair. To specify a **LABEL** without a value, simply use an empty
fbcbaa5
  string. To include spaces within a **LABEL** value, use quotes and
fbcbaa5
  backslashes as you would in command-line parsing.
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  LABEL com.example.vendor="ACME Incorporated"
fbcbaa5
  LABEL com.example.vendor "ACME Incorporated"
fbcbaa5
  LABEL com.example.vendor.is-beta ""
fbcbaa5
  LABEL com.example.vendor.is-beta=
fbcbaa5
  LABEL com.example.vendor.is-beta=""
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  An image can have more than one label. To specify multiple labels, separate
fbcbaa5
  each key-value pair by a space.
fbcbaa5
fbcbaa5
  Labels are additive including `LABEL`s in `FROM` images. As the system
fbcbaa5
  encounters and then applies a new label, new `key`s override any previous
fbcbaa5
  labels with identical keys.
fbcbaa5
fbcbaa5
  To display an image's labels, use the `buildah inspect` command.
fbcbaa5
fbcbaa5
**EXPOSE**
fbcbaa5
  -- `EXPOSE <port> [<port>...]`
fbcbaa5
  The **EXPOSE** instruction informs the container engine that the container listens on the
fbcbaa5
  specified network ports at runtime. The container engine uses this information to
fbcbaa5
  interconnect containers using links and to set up port redirection on the host
fbcbaa5
  system.
fbcbaa5
fbcbaa5
**ENV**
fbcbaa5
  -- `ENV <key> <value>`
fbcbaa5
  The **ENV** instruction sets the environment variable <key> to
fbcbaa5
  the value `<value>`. This value is passed to all future
fbcbaa5
  **RUN**, **ENTRYPOINT**, and **CMD** instructions. This is
fbcbaa5
  functionally equivalent to prefixing the command with `<key>=<value>`.  The
fbcbaa5
  environment variables that are set with **ENV** persist when a container is run
fbcbaa5
  from the resulting image. Use `podman inspect` to inspect these values, and
fbcbaa5
  change them using `podman run --env <key>=<value>`.
fbcbaa5
fbcbaa5
  Note that setting "`ENV DEBIAN_FRONTEND=noninteractive`" may cause
fbcbaa5
  unintended consequences, because it will persist when the container is run
fbcbaa5
  interactively, as with the following command: `podman run -t -i image bash`
fbcbaa5
fbcbaa5
**ADD**
fbcbaa5
  -- **ADD** has two forms:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  ADD <src> <dest>
fbcbaa5
fbcbaa5
  # Required for paths with whitespace
fbcbaa5
  ADD ["<src>",... "<dest>"]
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  The **ADD** instruction copies new files, directories
fbcbaa5
  or remote file URLs to the filesystem of the container at path `<dest>`.
fbcbaa5
  Multiple `<src>` resources may be specified but if they are files or directories
fbcbaa5
  then they must be relative to the source directory that is being built
fbcbaa5
  (the context of the build). The `<dest>` is the absolute path, or path relative
fbcbaa5
  to **WORKDIR**, into which the source is copied inside the target container.
fbcbaa5
  If the `<src>` argument is a local file in a recognized compression format
fbcbaa5
  (tar, gzip, bzip2, etc) then it is unpacked at the specified `<dest>` in the
fbcbaa5
  container's filesystem.  Note that only local compressed files will be unpacked,
fbcbaa5
  i.e., the URL download and archive unpacking features cannot be used together.
fbcbaa5
  All new directories are created with mode 0755 and with the uid and gid of **0**.
fbcbaa5
fbcbaa5
**COPY**
fbcbaa5
  -- **COPY** has two forms:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  COPY <src> <dest>
fbcbaa5
fbcbaa5
  # Required for paths with whitespace
fbcbaa5
  COPY ["<src>",... "<dest>"]
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  The **COPY** instruction copies new files from `<src>` and
0c713a7
  adds them to the filesystem of the container at path `<dest>`. The `<src>` must be
fbcbaa5
  the path to a file or directory relative to the source directory that is
fbcbaa5
  being built (the context of the build) or a remote file URL. The `<dest>` is an
fbcbaa5
  absolute path, or a path relative to **WORKDIR**, into which the source will
fbcbaa5
  be copied inside the target container. If you **COPY** an archive file it will
fbcbaa5
  land in the container exactly as it appears in the build context without any
fbcbaa5
  attempt to unpack it.  All new files and directories are created with mode **0755**
fbcbaa5
  and with the uid and gid of **0**.
fbcbaa5
fbcbaa5
**ENTRYPOINT**
fbcbaa5
  -- **ENTRYPOINT** has two forms:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  # executable form
fbcbaa5
  ENTRYPOINT ["executable", "param1", "param2"]`
fbcbaa5
fbcbaa5
  # run command in a shell - /bin/sh -c
fbcbaa5
  ENTRYPOINT command param1 param2
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  -- An **ENTRYPOINT** helps you configure a
fbcbaa5
  container that can be run as an executable. When you specify an **ENTRYPOINT**,
fbcbaa5
  the whole container runs as if it was only that executable.  The **ENTRYPOINT**
fbcbaa5
  instruction adds an entry command that is not overwritten when arguments are
fbcbaa5
  passed to `podman run`. This is different from the behavior of **CMD**. This allows
fbcbaa5
  arguments to be passed to the entrypoint, for instance `podman run <image> -d`
fbcbaa5
  passes the -d argument to the **ENTRYPOINT**.  Specify parameters either in the
fbcbaa5
  **ENTRYPOINT** JSON array (as in the preferred exec form above), or by using a **CMD**
fbcbaa5
  statement.  Parameters in the **ENTRYPOINT** are not overwritten by the `podman run` arguments.  Parameters specified via **CMD** are overwritten by `podman run` arguments.  Specify a plain string for the **ENTRYPOINT**, and it will execute in
fbcbaa5
  `/bin/sh -c`, like a **CMD** instruction:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM ubuntu
fbcbaa5
  ENTRYPOINT wc -l -
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  This means that the Containerfile's image always takes stdin as input (that's
fbcbaa5
  what "-" means), and prints the number of lines (that's what "-l" means). To
fbcbaa5
  make this optional but default, use a **CMD**:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM ubuntu
fbcbaa5
  CMD ["-l", "-"]
fbcbaa5
  ENTRYPOINT ["/usr/bin/wc"]
fbcbaa5
  ```
fbcbaa5
fbcbaa5
**VOLUME**
fbcbaa5
  -- `VOLUME ["/data"]`
fbcbaa5
  The **VOLUME** instruction creates a mount point with the specified name and marks
fbcbaa5
  it as holding externally-mounted volumes from the native host or from other
fbcbaa5
  containers.
fbcbaa5
fbcbaa5
**USER**
fbcbaa5
  -- `USER daemon`
fbcbaa5
  Sets the username or UID used for running subsequent commands.
fbcbaa5
fbcbaa5
  The **USER** instruction can optionally be used to set the group or GID. The
fbcbaa5
  following examples are all valid:
fbcbaa5
  USER [user | user:group | uid | uid:gid | user:gid | uid:group ]
fbcbaa5
fbcbaa5
  Until the **USER** instruction is set, instructions will be run as root. The USER
fbcbaa5
  instruction can be used any number of times in a Containerfile, and will only affect
fbcbaa5
  subsequent commands.
fbcbaa5
fbcbaa5
**WORKDIR**
fbcbaa5
  -- `WORKDIR /path/to/workdir`
fbcbaa5
  The **WORKDIR** instruction sets the working directory for the **RUN**, **CMD**,
fbcbaa5
  **ENTRYPOINT**, **COPY** and **ADD** Containerfile commands that follow it. It can
fbcbaa5
  be used multiple times in a single Containerfile. Relative paths are defined
fbcbaa5
  relative to the path of the previous **WORKDIR** instruction. For example:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  WORKDIR /a
fbcbaa5
  WORKDIR b
fbcbaa5
  WORKDIR c
fbcbaa5
  RUN pwd
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  In the above example, the output of the **pwd** command is **a/b/c**.
fbcbaa5
fbcbaa5
**ARG**
fbcbaa5
   -- ARG <name>[=<default value>]
fbcbaa5
fbcbaa5
  The `ARG` instruction defines a variable that users can pass at build-time to
fbcbaa5
  the builder with the `podman build` command using the `--build-arg
fbcbaa5
  <varname>=<value>` flag. If a user specifies a build argument that was not
fbcbaa5
  defined in the Containerfile, the build outputs a warning.
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  [Warning] One or more build-args [foo] were not consumed
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  The Containerfile author can define a single variable by specifying `ARG` once or many
fbcbaa5
  variables by specifying `ARG` more than once. For example, a valid Containerfile:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM busybox
fbcbaa5
  ARG user1
fbcbaa5
  ARG buildno
fbcbaa5
  ...
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  A Containerfile author may optionally specify a default value for an `ARG` instruction:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  FROM busybox
fbcbaa5
  ARG user1=someuser
fbcbaa5
  ARG buildno=1
fbcbaa5
  ...
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  If an `ARG` value has a default and if there is no value passed at build-time, the
fbcbaa5
  builder uses the default.
fbcbaa5
fbcbaa5
  An `ARG` variable definition comes into effect from the line on which it is
fbcbaa5
  defined in the `Containerfile` not from the argument's use on the command-line or
fbcbaa5
  elsewhere.  For example, consider this Containerfile:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  1 FROM busybox
fbcbaa5
  2 USER ${user:-some_user}
fbcbaa5
  3 ARG user
fbcbaa5
  4 USER $user
fbcbaa5
  ...
fbcbaa5
  ```
fbcbaa5
  A user builds this file by calling:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  $ podman build --build-arg user=what_user Containerfile
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  The `USER` at line 2 evaluates to `some_user` as the `user` variable is defined on the
fbcbaa5
  subsequent line 3. The `USER` at line 4 evaluates to `what_user` as `user` is
fbcbaa5
  defined and the `what_user` value was passed on the command line. Prior to its definition by an
fbcbaa5
  `ARG` instruction, any use of a variable results in an empty string.
fbcbaa5
fbcbaa5
  > **Warning:** It is not recommended to use build-time variables for
fbcbaa5
  >  passing secrets like github keys, user credentials etc. Build-time variable
fbcbaa5
  >  values are visible to any user of the image with the `podman history` command.
fbcbaa5
fbcbaa5
  You can use an `ARG` or an `ENV` instruction to specify variables that are
fbcbaa5
  available to the `RUN` instruction. Environment variables defined using the
fbcbaa5
  `ENV` instruction always override an `ARG` instruction of the same name. Consider
fbcbaa5
  this Containerfile with an `ENV` and `ARG` instruction.
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  1 FROM ubuntu
fbcbaa5
  2 ARG CONT_IMG_VER
fbcbaa5
  3 ENV CONT_IMG_VER=v1.0.0
fbcbaa5
  4 RUN echo $CONT_IMG_VER
fbcbaa5
  ```
fbcbaa5
  Then, assume this image is built with this command:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  $ podman build --build-arg CONT_IMG_VER=v2.0.1 Containerfile
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  In this case, the `RUN` instruction uses `v1.0.0` instead of the `ARG` setting
fbcbaa5
  passed by the user:`v2.0.1` This behavior is similar to a shell
fbcbaa5
  script where a locally scoped variable overrides the variables passed as
fbcbaa5
  arguments or inherited from environment, from its point of definition.
fbcbaa5
fbcbaa5
  Using the example above but a different `ENV` specification you can create more
fbcbaa5
  useful interactions between `ARG` and `ENV` instructions:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  1 FROM ubuntu
fbcbaa5
  2 ARG CONT_IMG_VER
fbcbaa5
  3 ENV CONT_IMG_VER=${CONT_IMG_VER:-v1.0.0}
fbcbaa5
  4 RUN echo $CONT_IMG_VER
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  Unlike an `ARG` instruction, `ENV` values are always persisted in the built
fbcbaa5
  image. Consider a `podman build` without the --build-arg flag:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  $ podman build Containerfile
fbcbaa5
  ```
fbcbaa5
fbcbaa5
  Using this Containerfile example, `CONT_IMG_VER` is still persisted in the image but
fbcbaa5
  its value would be `v1.0.0` as it is the default set in line 3 by the `ENV` instruction.
fbcbaa5
fbcbaa5
  The variable expansion technique in this example allows you to pass arguments
fbcbaa5
  from the command line and persist them in the final image by leveraging the
fbcbaa5
  `ENV` instruction. Variable expansion is only supported for [a limited set of
fbcbaa5
  Containerfile instructions.](#environment-replacement)
fbcbaa5
fbcbaa5
  Container engines have a set of predefined `ARG` variables that you can use without a
fbcbaa5
  corresponding `ARG` instruction in the Containerfile.
fbcbaa5
fbcbaa5
  * `HTTP_PROXY`
fbcbaa5
  * `http_proxy`
fbcbaa5
  * `HTTPS_PROXY`
fbcbaa5
  * `https_proxy`
fbcbaa5
  * `FTP_PROXY`
fbcbaa5
  * `ftp_proxy`
fbcbaa5
  * `NO_PROXY`
fbcbaa5
  * `no_proxy`
fbcbaa5
  * `ALL_PROXY`
fbcbaa5
  * `all_proxy`
fbcbaa5
fbcbaa5
  To use these, pass them on the command line using `--build-arg` flag, for
fbcbaa5
  example:
fbcbaa5
fbcbaa5
  ```
fbcbaa5
  $ podman build --build-arg HTTPS_PROXY=https://my-proxy.example.com .
fbcbaa5
  ```
fbcbaa5
fbcbaa5
**ONBUILD**
fbcbaa5
  -- `ONBUILD [INSTRUCTION]`
fbcbaa5
  The **ONBUILD** instruction adds a trigger instruction to an image. The
fbcbaa5
  trigger is executed at a later time, when the image is used as the base for
fbcbaa5
  another build. Container engines execute the trigger in the context of the downstream
fbcbaa5
  build, as if the trigger existed immediately after the **FROM** instruction in
fbcbaa5
  the downstream Containerfile.
fbcbaa5
fbcbaa5
  You can register any build instruction as a trigger. A trigger is useful if
fbcbaa5
  you are defining an image to use as a base for building other images. For
fbcbaa5
  example, if you are defining an application build environment or a daemon that
fbcbaa5
  is customized with a user-specific configuration.
fbcbaa5
fbcbaa5
  Consider an image intended as a reusable python application builder. It must
fbcbaa5
  add application source code to a particular directory, and might need a build
fbcbaa5
  script called after that. You can't just call **ADD** and **RUN** now, because
fbcbaa5
  you don't yet have access to the application source code, and it is different
fbcbaa5
  for each application build.
fbcbaa5
fbcbaa5
  -- Providing application developers with a boilerplate Containerfile to copy-paste
fbcbaa5
  into their application is inefficient, error-prone, and
fbcbaa5
  difficult to update because it mixes with application-specific code.
fbcbaa5
  The solution is to use **ONBUILD** to register instructions in advance, to
fbcbaa5
  run later, during the next build stage.
fbcbaa5
fbcbaa5
## SEE ALSO
fbcbaa5
buildah(1), podman(1), docker(1)
fbcbaa5
fbcbaa5
# HISTORY
fbcbaa5
*May 2014, Compiled by Zac Dover (zdover at redhat dot com) based on docker.com Dockerfile documentation.
fbcbaa5
*Feb 2015, updated by Brian Goff (cpuguy83@gmail.com) for readability
fbcbaa5
*Sept 2015, updated by Sally O'Malley (somalley@redhat.com)
fbcbaa5
*Oct 2016, updated by Addam Hardy (addam.hardy@gmail.com)
fbcbaa5
*Aug 2021, converted Dockerfile man page to Containerfile by Dan Walsh (dwalsh@redhat.com)