github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/docs/source/markdown/podman-build.1.md (about)

     1  % podman-build(1)
     2  
     3  ## NAME
     4  podman\-build - Build a container image using a Containerfile
     5  
     6  ## SYNOPSIS
     7  **podman build** [*options*] [*context*]
     8  
     9  **podman image build** [*options*] [*context*]
    10  
    11  ## DESCRIPTION
    12  **podman build** Builds an image using instructions from one or more
    13  Containerfiles or Dockerfiles and a specified build context directory. A
    14  Containerfile uses the same syntax as a Dockerfile internally. For this
    15  document, a file referred to as a Containerfile can be a file named either
    16  'Containerfile' or 'Dockerfile'.
    17  
    18  The build context directory can be specified as the http(s) URL of an archive,
    19  git repository or Containerfile.
    20  
    21  If no context directory is specified, then Podman will assume the current
    22  working directory as the build context, which should contain the Containerfile.
    23  
    24  Containerfiles ending with a ".in" suffix will be preprocessed via CPP(1).  This
    25  can be useful to decompose Containerfiles into several reusable parts that can
    26  be used via CPP's **#include** directive.  Notice, a Containerfile.in file can
    27  still be used by other tools when manually preprocessing them via `cpp -E`.
    28  
    29  When the URL is an archive, the contents of the URL is downloaded to a temporary
    30  location and extracted before execution.
    31  
    32  When the URL is an Containerfile, the Containerfile is downloaded to a temporary
    33  location.
    34  
    35  When a Git repository is set as the URL, the repository is cloned locally and
    36  then set as the context.
    37  
    38  NOTE: `podman build` uses code sourced from the `buildah` project to build
    39  container images.  This `buildah` code creates `buildah` containers for the
    40  `RUN` options in container storage. In certain situations, when the
    41  `podman build` crashes or users kill the `podman build` process, these external
    42  containers can be left in container storage. Use the `podman ps --all --storage`
    43  command to see these contaienrs. External containers can be removed with the
    44  `podman rm --storage` command.
    45  
    46  ## OPTIONS
    47  
    48  #### **--add-host**=*host*
    49  
    50  Add a custom host-to-IP mapping (host:ip)
    51  
    52  Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** option
    53  can be set multiple times.
    54  
    55  #### **--annotation**=*annotation*
    56  
    57  Add an image *annotation* (e.g. annotation=*value*) to the image metadata. Can
    58  be used multiple times.
    59  
    60  Note: this information is not present in Docker image formats, so it is
    61  discarded when writing images in Docker formats.
    62  
    63  #### **--arch**=*arch*
    64  
    65  Set the ARCH of the image to the provided value instead of the architecture of
    66  the host.
    67  
    68  #### **--authfile**=*path*
    69  
    70  Path of the authentication file. Default is
    71  ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`.
    72  If the authorization state is not found there, $HOME/.docker/config.json is
    73  checked, which is set using `docker login`.
    74  
    75  Note: You can also override the default path of the authentication file by
    76  setting the REGISTRY\_AUTH\_FILE environment variable.
    77  `export REGISTRY_AUTH_FILE=path`
    78  
    79  #### **--build-arg**=*arg=value*
    80  
    81  Specifies a build argument and its value, which will be interpolated in
    82  instructions read from the Containerfiles in the same way that environment
    83  variables are, but which will not be added to environment variable list in the
    84  resulting image's configuration.
    85  
    86  #### **--cache-from**
    87  
    88  Images to utilize as potential cache sources. Podman does not currently support
    89  caching so this is a NOOP.
    90  
    91  #### **--cap-add**=*CAP\_xxx*
    92  
    93  When executing RUN instructions, run the command specified in the instruction
    94  with the specified capability added to its capability set.
    95  Certain capabilities are granted by default; this option can be used to add
    96  more.
    97  
    98  #### **--cap-drop**=*CAP\_xxx*
    99  
   100  When executing RUN instructions, run the command specified in the instruction
   101  with the specified capability removed from its capability set.
   102  The CAP\_AUDIT\_WRITE, CAP\_CHOWN, CAP\_DAC\_OVERRIDE, CAP\_FOWNER,
   103  CAP\_FSETID, CAP\_KILL, CAP\_MKNOD, CAP\_NET\_BIND\_SERVICE, CAP\_SETFCAP,
   104  CAP\_SETGID, CAP\_SETPCAP, CAP\_SETUID, and CAP\_SYS\_CHROOT capabilities are
   105  granted by default; this option can be used to remove them.
   106  
   107  If a capability is specified to both the **--cap-add** and **--cap-drop**
   108  options, it will be dropped, regardless of the order in which the options were
   109  given.
   110  
   111  #### **--cert-dir**=*path*
   112  
   113  Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
   114  Default certificates directory is _/etc/containers/certs.d_. (Not available for
   115  remote commands)
   116  
   117  #### **--cgroup-parent**=*path*
   118  
   119  Path to cgroups under which the cgroup for the container will be created. If the
   120  path is not absolute, the path is considered to be relative to the cgroups path
   121  of the init process. Cgroups will be created if they do not already exist.
   122  
   123  #### **--compress**
   124  
   125  This option is added to be aligned with other containers CLIs.
   126  Podman doesn't communicate with a daemon or a remote server.
   127  Thus, compressing the data before sending it is irrelevant to Podman.
   128  
   129  #### **--cni-config-dir**=*directory*
   130  
   131  Location of CNI configuration files which will dictate which plugins will be
   132  used to configure network interfaces and routing for containers created for
   133  handling `RUN` instructions, if those containers will be run in their own
   134  network namespaces, and networking is not disabled.
   135  
   136  #### **--cni-plugin-path**=*directory[:directory[:directory[...]]]*
   137  
   138  List of directories in which the CNI plugins which will be used for configuring
   139  network namespaces can be found.
   140  
   141  #### **--cpu-period**=*limit*
   142  
   143  Set the CPU period for the Completely Fair Scheduler (CFS), which is a
   144  duration in microseconds. Once the container's CPU quota is used up, it will
   145  not be scheduled to run until the current period ends. Defaults to 100000
   146  microseconds.
   147  
   148  On some systems, changing the CPU limits may not be allowed for non-root
   149  users. For more details, see
   150  https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error
   151  
   152  #### **--cpu-quota**=*limit*
   153  
   154  Limit the CPU Completely Fair Scheduler (CFS) quota.
   155  
   156  Limit the container's CPU usage. By default, containers run with the full
   157  CPU resource. The limit is a number in microseconds. If you provide a number,
   158  the container will be allowed to use that much CPU time until the CPU period
   159  ends (controllable via **--cpu-period**).
   160  
   161  On some systems, changing the CPU limits may not be allowed for non-root
   162  users. For more details, see
   163  https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error
   164  
   165  #### **--cpu-shares**, **-c**=*shares*
   166  
   167  CPU shares (relative weight)
   168  
   169  By default, all containers get the same proportion of CPU cycles. This
   170  proportion can be modified by changing the container's CPU share weighting
   171  relative to the weighting of all other running containers.
   172  
   173  To modify the proportion from the default of 1024, use the **--cpu-shares**
   174  flag to set the weighting to 2 or higher.
   175  
   176  The proportion will only apply when CPU-intensive processes are running.
   177  When tasks in one container are idle, other containers can use the
   178  left-over CPU time. The actual amount of CPU time will vary depending on
   179  the number of containers running on the system.
   180  
   181  For example, consider three containers, one has a cpu-share of 1024 and
   182  two others have a cpu-share setting of 512. When processes in all three
   183  containers attempt to use 100% of CPU, the first container would receive
   184  50% of the total CPU time. If you add a fourth container with a cpu-share
   185  of 1024, the first container only gets 33% of the CPU. The remaining containers
   186  receive 16.5%, 16.5% and 33% of the CPU.
   187  
   188  On a multi-core system, the shares of CPU time are distributed over all CPU
   189  cores. Even if a container is limited to less than 100% of CPU time, it can
   190  use 100% of each individual CPU core.
   191  
   192  For example, consider a system with more than three cores. If you start one
   193  container **{C0}** with **-c=512** running one process, and another container
   194  **{C1}** with **-c=1024** running two processes, this can result in the
   195  following
   196  division of CPU shares:
   197  
   198      PID    container	CPU	CPU share
   199      100    {C0}		0	100% of CPU0
   200      101    {C1}		1	100% of CPU1
   201      102    {C1}		2	100% of CPU2
   202  
   203  #### **--cpuset-cpus**=*num*
   204  
   205    CPUs in which to allow execution (0-3, 0,1)
   206  
   207  #### **--cpuset-mems**=*nodes*
   208  
   209  Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on
   210  NUMA systems.
   211  
   212  If you have four memory nodes on your system (0-3), use `--cpuset-mems=0,1`
   213  then processes in your container will only use memory from the first
   214  two memory nodes.
   215  
   216  #### **--creds**=*creds*
   217  
   218  The [username[:password]] to use to authenticate with the registry if required.
   219  If one or both values are not supplied, a command line prompt will appear and
   220  the value can be entered.  The password is entered without echo.
   221  
   222  #### **--decryption-key**=*key[:passphrase]*
   223  
   224  The [key[:passphrase]] to be used for decryption of images. Key can point to
   225  keys and/or certificates. Decryption will be tried with all keys. If the key is
   226  protected by a passphrase, it is required to be passed in the argument and
   227  omitted otherwise.
   228  
   229  #### **--device**=_host-device_[**:**_container-device_][**:**_permissions_]
   230  
   231  Add a host device to the container. Optional *permissions* parameter
   232  can be used to specify device permissions, it is combination of
   233  **r** for read, **w** for write, and **m** for **mknod**(2).
   234  
   235  Example: **--device=/dev/sdc:/dev/xvdc:rwm**.
   236  
   237  Note: if _host_device_ is a symbolic link then it will be resolved first.
   238  The container will only store the major and minor numbers of the host device.
   239  
   240  Note: if the user only has access rights via a group, accessing the device
   241  from inside a rootless container will fail. The **crun**(1) runtime offers a
   242  workaround for this by adding the option
   243  #### **--annotation run.oci.keep_original_groups=1**.
   244  
   245  #### **--disable-compression**, **-D**
   246  
   247  Don't compress filesystem layers when building the image unless it is required
   248  by the location where the image is being written.  This is the default setting,
   249  because image layers are compressed automatically when they are pushed to
   250  registries, and images being written to local storage would only need to be
   251  decompressed again to be stored.  Compression can be forced in all cases by
   252  specifying **--disable-compression=false**.
   253  
   254  #### **--disable-content-trust**
   255  
   256  This is a Docker specific option to disable image verification to a Docker
   257  registry and is not supported by Podman.  This flag is a NOOP and provided
   258  solely for scripting compatibility.
   259  
   260  #### **--dns**=*dns*
   261  
   262  Set custom DNS servers
   263  
   264  This option can be used to override the DNS configuration passed to the
   265  container. Typically this is necessary when the host DNS configuration is
   266  invalid for the container (e.g., 127.0.0.1). When this is the case the `--dns`
   267  flag is necessary for every run.
   268  
   269  The special value **none** can be specified to disable creation of
   270  /etc/resolv.conf in the container by Podman. The /etc/resolv.conf file in the
   271  image will be used without changes.
   272  
   273  #### **--dns-option**=*option*
   274  
   275  Set custom DNS options
   276  
   277  #### **--dns-search**=*domain*
   278  
   279  Set custom DNS search domains
   280  
   281  #### **--file**, **-f**=*Containerfile*
   282  
   283  Specifies a Containerfile which contains instructions for building the image,
   284  either a local file or an **http** or **https** URL.  If more than one
   285  Containerfile is specified, *FROM* instructions will only be accepted from the
   286  first specified file.
   287  
   288  If a build context is not specified, and at least one Containerfile is a
   289  local file, the directory in which it resides will be used as the build
   290  context.
   291  
   292  If you specify `-f -`, the Containerfile contents will be read from stdin.
   293  
   294  #### **--force-rm**=*true|false*
   295  
   296  Always remove intermediate containers after a build, even if the build fails
   297  (default false).
   298  
   299  #### **--format**
   300  
   301  Control the format for the built image's manifest and configuration data.
   302  Recognized formats include *oci* (OCI image-spec v1.0, the default) and
   303  *docker* (version 2, using schema format 2 for the manifest).
   304  
   305  Note: You can also override the default format by setting the BUILDAH\_FORMAT
   306  environment variable.  `export BUILDAH_FORMAT=docker`
   307  
   308  **-h**, **--help**
   309  
   310  Print usage statement
   311  
   312  #### **--http-proxy**
   313  
   314  Pass through HTTP Proxy environment variables.
   315  
   316  #### **--iidfile**=*ImageIDfile*
   317  
   318  Write the image ID to the file.
   319  
   320  #### **--ipc**=*how*
   321  
   322  Sets the configuration for IPC namespaces when handling `RUN` instructions.
   323  The configured value can be "" (the empty string) or "container" to indicate
   324  that a new IPC namespace should be created, or it can be "host" to indicate
   325  that the IPC namespace in which `podman` itself is being run should be reused,
   326  or it can be the path to an IPC namespace which is already in use by
   327  another process.
   328  
   329  #### **--isolation**=*type*
   330  
   331  Controls what type of isolation is used for running processes as part of `RUN`
   332  instructions.  Recognized types include *oci* (OCI-compatible runtime, the
   333  default), *rootless* (OCI-compatible runtime invoked using a modified
   334  configuration and its --rootless flag enabled, with *--no-new-keyring
   335  --no-pivot* added to its *create* invocation, with network and UTS namespaces
   336  disabled, and IPC, PID, and user namespaces enabled; the default for
   337  unprivileged users), and *chroot* (an internal wrapper that leans more toward
   338  chroot(1) than container technology).
   339  
   340  Note: You can also override the default isolation type by setting the
   341  BUILDAH\_ISOLATION environment variable.  `export BUILDAH_ISOLATION=oci`
   342  
   343  #### **--jobs**=*number*
   344  
   345  Run up to N concurrent stages in parallel.  If the number of jobs is greater
   346  than 1, stdin will be read from /dev/null.  If 0 is specified, then there is
   347  no limit in the number of jobs that run in parallel.
   348  
   349  #### **--label**=*label*
   350  
   351  Add an image *label* (e.g. label=*value*) to the image metadata. Can be used
   352  multiple times.
   353  
   354  Users can set a special LABEL **io.containers.capabilities=CAP1,CAP2,CAP3** in
   355  a Containerfile that specified the list of Linux capabilities required for the
   356  container to run properly. This label specified in a container image tells
   357  Podman to run the container with just these capabilities. Podman launches the
   358  container with just the specified capabilities, as long as this list of
   359  capabilities is a subset of the default list.
   360  
   361  If the specified capabilities are not in the default set, Podman will
   362  print an error message and will run the container with the default capabilities.
   363  
   364  #### **--layers**
   365  
   366  Cache intermediate images during the build process (Default is `true`).
   367  
   368  Note: You can also override the default value of layers by setting the
   369  BUILDAH\_LAYERS environment variable. `export BUILDAH_LAYERS=true`
   370  
   371  #### **--logfile**=*filename*
   372  
   373  Log output which would be sent to standard output and standard error to the
   374  specified file instead of to standard output and standard error.
   375  
   376  #### **--loglevel**=*number*
   377  
   378  Adjust the logging level up or down.  Valid option values range from -2 to 3,
   379  with 3 being roughly equivalent to using the global *--debug* option, and
   380  values below 0 omitting even error messages which accompany fatal errors.
   381  
   382  #### **--memory**, **-m**=*LIMIT*
   383  Memory limit (format: <number>[<unit>], where unit = b (bytes), k (kilobytes),
   384  m (megabytes), or g (gigabytes))
   385  
   386  Allows you to constrain the memory available to a container. If the host
   387  supports swap memory, then the **-m** memory setting can be larger than physical
   388  RAM. If a limit of 0 is specified (not using **-m**), the container's memory is
   389  not limited. The actual limit may be rounded up to a multiple of the operating
   390  system's page size (the value would be very large, that's millions of
   391  trillions).
   392  
   393  #### **--memory-swap**=*LIMIT*
   394  
   395  A limit value equal to memory plus swap. Must be used with the  **-m**
   396  (**--memory**) flag. The swap `LIMIT` should always be larger than **-m**
   397  (**--memory**) value.  By default, the swap `LIMIT` will be set to double
   398  the value of --memory.
   399  
   400  The format of `LIMIT` is `<number>[<unit>]`. Unit can be `b` (bytes),
   401  `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a
   402  unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap.
   403  
   404  #### **--network**=*mode*, **--net**
   405  
   406  Sets the configuration for network namespaces when handling `RUN` instructions.
   407  
   408  Valid _mode_ values are:
   409  
   410  - **none**: no networking.
   411  - **host**: use the Podman host network stack. Note: the host mode gives the
   412  container full access to local system services such as D-bus and is therefore
   413  considered insecure.
   414  - **ns:**_path_: path to a network namespace to join.
   415  - **private**: create a new namespace for the container (default). The
   416  **container** network mode is an alias for **private**, but has been deprecated
   417  and will be removed in a future release of Podman.
   418  
   419  #### **--no-cache**
   420  
   421  Do not use existing cached images for the container build. Build from the start
   422  with a new set of cached layers.
   423  
   424  #### **--os**=*string*
   425  
   426  Set the OS to the provided value instead of the current operating system of the
   427  host.
   428  
   429  #### **--pid**=*pid*
   430  
   431  Sets the configuration for PID namespaces when handling `RUN` instructions.
   432  The configured value can be "" (the empty string) or "container" to indicate
   433  that a new PID namespace should be created, or it can be "host" to indicate
   434  that the PID namespace in which `podman` itself is being run should be reused,
   435  or it can be the path to a PID namespace which is already in use by another
   436  process.
   437  
   438  #### **--platform**="Linux"
   439  
   440  This option has no effect on the build. Other container engines use this option
   441  to control the execution platform for the build (e.g., Windows, Linux) which is
   442  not required for Buildah as it supports only Linux.
   443  
   444  #### **--pull**
   445  
   446  When the option is specified or set to "true", pull the image from the first
   447  registry it is found in as listed in registries.conf.  Raise an error if not
   448  found in the registries, even if the image is present locally.
   449  
   450  If the option is disabled (with *--pull=false*) or not specified, pull the
   451  image from the registry only if the image is not present locally. Raise an
   452  error if the image is not found in the registries and is not present locally.
   453  
   454  #### **--pull-always**
   455  
   456  Pull the image from the first registry it is found in as listed in
   457  registries.conf. Raise an error if not found in the registries, even if the
   458  image is present locally.
   459  
   460  #### **--pull-never**
   461  
   462  Do not pull the image from the registry, use only the local version. Raise an
   463  error if the image is not present locally.
   464  
   465  #### **--quiet**, **-q**
   466  
   467  Suppress output messages which indicate which instruction is being processed,
   468  and of progress when pulling images from a registry, and when writing the
   469  output image.
   470  
   471  #### **--rm**=*true|false*
   472  
   473  Remove intermediate containers after a successful build (default true).
   474  
   475  #### **--runtime**=*path*
   476  
   477  The *path* to an alternate OCI-compatible runtime, which will be used to run
   478  commands specified by the **RUN** instruction.
   479  
   480  Note: You can also override the default runtime by setting the BUILDAH\_RUNTIME
   481  environment variable.  `export BUILDAH_RUNTIME=/usr/local/bin/runc`
   482  
   483  #### **--security-opt**=*option*
   484  
   485  Security Options
   486  
   487  - `apparmor=unconfined` : Turn off apparmor confinement for the container
   488  - `apparmor=your-profile` : Set the apparmor confinement profile for the
   489  container
   490  
   491  - `label=user:USER`     : Set the label user for the container processes
   492  - `label=role:ROLE`     : Set the label role for the container processes
   493  - `label=type:TYPE`     : Set the label process type for the container processes
   494  - `label=level:LEVEL`   : Set the label level for the container processes
   495  - `label=filetype:TYPE` : Set the label file type for the container files
   496  - `label=disable`       : Turn off label separation for the container
   497  - `no-new-privileges`   : Not supported
   498  
   499  - `seccomp=unconfined` : Turn off seccomp confinement for the container
   500  - `seccomp=profile.json` :  White listed syscalls seccomp Json file to be used
   501  as a seccomp filter
   502  
   503  #### **--shm-size**=*size*
   504  
   505  Size of `/dev/shm`. The format is `<number><unit>`. `number` must be greater
   506  than `0`.
   507  Unit is optional and can be `b` (bytes), `k` (kilobytes), `m`(megabytes), or
   508  `g` (gigabytes). If you omit the unit, the system uses bytes. If you omit the
   509  size entirely, the system uses `64m`.
   510  
   511  #### **--sign-by**=*fingerprint*
   512  
   513  Sign the image using a GPG key with the specified FINGERPRINT.
   514  
   515  #### **--squash**
   516  
   517  Squash all of the image's new layers into a single new layer; any preexisting
   518  layers are not squashed.
   519  
   520  #### **--squash-all**
   521  
   522  Squash all of the new image's layers (including those inherited from a base
   523  image) into a single new layer.
   524  
   525  #### **--tag**, **-t**=*imageName*
   526  
   527  Specifies the name which will be assigned to the resulting image if the build
   528  process completes successfully.
   529  If _imageName_ does not include a registry name, the registry name *localhost*
   530  will be prepended to the image name.
   531  
   532  #### **--target**=*stageName*
   533  
   534  Set the target build stage to build.  When building a Containerfile with
   535  multiple build stages, --target can be used to specify an intermediate build
   536  stage by name as the final stage for the resulting image. Commands after the target stage will be skipped.
   537  
   538  #### **--timestamp** *seconds*
   539  
   540  Set the create timestamp to seconds since epoch to allow for deterministic
   541  builds (defaults to current time). By default, the created timestamp is changed
   542  and written into the image manifest with every commit, causing the image's
   543  sha256 hash to be different even if the sources are exactly the same otherwise.
   544  When --timestamp is set, the created timestamp is always set to the time
   545  specified and therefore not changed, allowing the image's sha256 hash to remain the
   546  same. All files committed to the layers of the image will be created with the
   547  timestamp.
   548  
   549  #### **--tls-verify**=*true|false*
   550  
   551  Require HTTPS and verify certificates when talking to container registries
   552  (defaults to true).
   553  
   554  #### **--ulimit**=*type*=*soft-limit*[:*hard-limit*]
   555  
   556  Specifies resource limits to apply to processes launched when processing `RUN`
   557  instructions. This option can be specified multiple times.  Recognized resource
   558  types include:
   559    "core": maximum core dump size (ulimit -c)
   560    "cpu": maximum CPU time (ulimit -t)
   561    "data": maximum size of a process's data segment (ulimit -d)
   562    "fsize": maximum size of new files (ulimit -f)
   563    "locks": maximum number of file locks (ulimit -x)
   564    "memlock": maximum amount of locked memory (ulimit -l)
   565    "msgqueue": maximum amount of data in message queues (ulimit -q)
   566    "nice": niceness adjustment (nice -n, ulimit -e)
   567    "nofile": maximum number of open files (ulimit -n)
   568    "nproc": maximum number of processes (ulimit -u)
   569    "rss": maximum size of a process's (ulimit -m)
   570    "rtprio": maximum real-time scheduling priority (ulimit -r)
   571    "rttime": maximum amount of real-time execution between blocking syscalls
   572    "sigpending": maximum number of pending signals (ulimit -i)
   573    "stack": maximum stack size (ulimit -s)
   574  
   575  #### **--userns**=*how*
   576  
   577  Sets the configuration for user namespaces when handling `RUN` instructions.
   578  The configured value can be "" (the empty string) or "container" to indicate
   579  that a new user namespace should be created, it can be "host" to indicate that
   580  the user namespace in which `podman` itself is being run should be reused, or
   581  it can be the path to an user namespace which is already in use by another
   582  process.
   583  
   584  #### **--userns-uid-map**=*mapping*
   585  
   586  Directly specifies a UID mapping which should be used to set ownership, at the
   587  filesystem level, on the working container's contents.
   588  Commands run when handling `RUN` instructions will default to being run in
   589  their own user namespaces, configured using the UID and GID maps.
   590  
   591  Entries in this map take the form of one or more triples of a starting
   592  in-container UID, a corresponding starting host-level UID, and the number of
   593  consecutive IDs which the map entry represents.
   594  
   595  This option overrides the *remap-uids* setting in the *options* section of
   596  /etc/containers/storage.conf.
   597  
   598  If this option is not specified, but a global --userns-uid-map setting is
   599  supplied, settings from the global option will be used.
   600  
   601  If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-uid-map
   602  are specified, but --userns-gid-map is specified, the UID map will be set to
   603  use the same numeric values as the GID map.
   604  
   605  #### **--userns-gid-map**=*mapping*
   606  
   607  Directly specifies a GID mapping which should be used to set ownership, at the
   608  filesystem level, on the working container's contents.
   609  Commands run when handling `RUN` instructions will default to being run in
   610  their own user namespaces, configured using the UID and GID maps.
   611  
   612  Entries in this map take the form of one or more triples of a starting
   613  in-container GID, a corresponding starting host-level GID, and the number of
   614  consecutive IDs which the map entry represents.
   615  
   616  This option overrides the *remap-gids* setting in the *options* section of
   617  /etc/containers/storage.conf.
   618  
   619  If this option is not specified, but a global --userns-gid-map setting is
   620  supplied, settings from the global option will be used.
   621  
   622  If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-gid-map
   623  are specified, but --userns-uid-map is specified, the GID map will be set to
   624  use the same numeric values as the UID map.
   625  
   626  #### **--userns-uid-map-user**=*user*
   627  
   628  Specifies that a UID mapping which should be used to set ownership, at the
   629  filesystem level, on the working container's contents, can be found in entries
   630  in the `/etc/subuid` file which correspond to the specified user.
   631  Commands run when handling `RUN` instructions will default to being run in
   632  their own user namespaces, configured using the UID and GID maps.
   633  If --userns-gid-map-group is specified, but --userns-uid-map-user is not
   634  specified, `podman` will assume that the specified group name is also a
   635  suitable user name to use as the default setting for this option.
   636  
   637  #### **--userns-gid-map-group**=*group*
   638  
   639  Specifies that a GID mapping which should be used to set ownership, at the
   640  filesystem level, on the working container's contents, can be found in entries
   641  in the `/etc/subgid` file which correspond to the specified group.
   642  Commands run when handling `RUN` instructions will default to being run in
   643  their own user namespaces, configured using the UID and GID maps.
   644  If --userns-uid-map-user is specified, but --userns-gid-map-group is not
   645  specified, `podman` will assume that the specified user name is also a
   646  suitable group name to use as the default setting for this option.
   647  
   648  #### **--uts**=*how*
   649  
   650  Sets the configuration for UTS namespaces when the handling `RUN` instructions.
   651  The configured value can be "" (the empty string) or "container" to indicate
   652  that a new UTS namespace should be created, or it can be "host" to indicate
   653  that the UTS namespace in which `podman` itself is being run should be reused,
   654  or it can be the path to a UTS namespace which is already in use by another
   655  process.
   656  
   657  #### **--volume**, **-v**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*]
   658  
   659     Create a bind mount. If you specify, ` -v /HOST-DIR:/CONTAINER-DIR`, Podman
   660     bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Podman
   661     container. The `OPTIONS` are a comma delimited list and can be: <sup>[[1]](#Footnote1)</sup>
   662  
   663     * [rw|ro]
   664     * [z|Z|O]
   665     * [`[r]shared`|`[r]slave`|`[r]private`]
   666  
   667  The `CONTAINER-DIR` must be an absolute path such as `/src/docs`. The `HOST-DIR`
   668  must be an absolute path as well. Podman bind-mounts the `HOST-DIR` to the
   669  path you specify. For example, if you supply `/foo` as the host path,
   670  Podman copies the contents of `/foo` to the container filesystem on the host
   671  and bind mounts that into the container.
   672  
   673  You can specify multiple  **-v** options to mount one or more mounts to a
   674  container.
   675  
   676  You can add the `:ro` or `:rw` suffix to a volume to mount it read-only or
   677  read-write mode, respectively. By default, the volumes are mounted read-write.
   678  See examples.
   679  
   680    `Labeling Volume Mounts`
   681  
   682  Labeling systems like SELinux require that proper labels are placed on volume
   683  content mounted into a container. Without a label, the security system might
   684  prevent the processes running inside the container from using the content. By
   685  default, Podman does not change the labels set by the OS.
   686  
   687  To change a label in the container context, you can add either of two suffixes
   688  `:z` or `:Z` to the volume mount. These suffixes tell Podman to relabel file
   689  objects on the shared volumes. The `z` option tells Podman that two containers
   690  share the volume content. As a result, Podman labels the content with a shared
   691  content label. Shared volume labels allow all containers to read/write content.
   692  The `Z` option tells Podman to label the content with a private unshared label.
   693  Only the current container can use a private volume.
   694  
   695    `Overlay Volume Mounts`
   696  
   697     The `:O` flag tells Podman to mount the directory from the host as a
   698  temporary storage using the Overlay file system. The `RUN` command containers
   699  are allowed to modify contents within the mountpoint and are stored in the
   700  container storage in a separate directory.  In Overlay FS terms the source
   701  directory will be the lower, and the container storage directory will be the
   702  upper. Modifications to the mount point are destroyed when the `RUN` command
   703  finishes executing, similar to a tmpfs mount point.
   704  
   705    Any subsequent execution of `RUN` commands sees the original source directory
   706  content, any changes from previous RUN commands no longer exists.
   707  
   708    One use case of the `overlay` mount is sharing the package cache from the
   709  host into the container to allow speeding up builds.
   710  
   711    Note:
   712  
   713       - Overlay mounts are not currently supported in rootless mode.
   714       - The `O` flag is not allowed to be specified with the `Z` or `z` flags.
   715  Content mounted into the container is labeled with the private label.
   716         On SELinux systems, labels in the source directory needs to be readable
   717  by the container label. If not, SELinux container separation must be disabled
   718  for the container to work.
   719       - Modification of the directory volume mounted into the container with an
   720  overlay mount can cause unexpected failures.  It is recommended that you do not
   721  modify the directory until the container finishes running.
   722  
   723  By default bind mounted volumes are `private`. That means any mounts done
   724  inside containers will not be visible on the host and vice versa. This behavior
   725  can be changed by specifying a volume mount propagation property.
   726  
   727  When the mount propagation policy is set to `shared`, any mounts completed
   728  inside the container on that volume will be visible to both the host and
   729  container. When the mount propagation policy is set to `slave`, one way mount
   730  propagation is enabled and any mounts completed on the host for that volume will
   731  be visible only inside of the container. To control the mount propagation
   732  property of volume use the `:[r]shared`, `:[r]slave` or `:[r]private`
   733  propagation flag. The propagation property can be specified only for bind mounted
   734  volumes and not for internal volumes or named volumes. For mount propagation to
   735  work on the source mount point (mount point where source dir is mounted on) has
   736  to have the right propagation properties. For shared volumes, the source mount
   737  point has to be shared. And for slave volumes, the source mount has to be either
   738  shared or slave. <sup>[[1]](#Footnote1)</sup>
   739  
   740  Use `df <source-dir>` to determine the source mount and then use
   741  `findmnt -o TARGET,PROPAGATION <source-mount-dir>` to determine propagation
   742  properties of source mount, if `findmnt` utility is not available, the source
   743  mount point can be determined by looking at the mount entry in
   744  `/proc/self/mountinfo`. Look at `optional fields` and see if any propagation
   745  properties are specified.
   746  `shared:X` means the mount is `shared`, `master:X` means the mount is `slave`
   747  and if nothing is there that means the mount is `private`. <sup>[[1]](#Footnote1)</sup>
   748  
   749  To change propagation properties of a mount point use the `mount` command. For
   750  example, to bind mount the source directory `/foo` do
   751  `mount --bind /foo /foo` and `mount --make-private --make-shared /foo`. This
   752  will convert /foo into a `shared` mount point.  The propagation properties of
   753  the source mount can be changed directly. For instance if `/` is the source
   754  mount for `/foo`, then use `mount --make-shared /` to convert `/` into a
   755  `shared` mount.
   756  
   757  ## EXAMPLES
   758  
   759  ### Build an image using local Containerfiles
   760  
   761  ```
   762  $ podman build .
   763  
   764  $ podman build -f Containerfile.simple .
   765  
   766  $ cat $HOME/Dockerfile | podman build -f - .
   767  
   768  $ podman build -f Dockerfile.simple -f Containerfile.notsosimple .
   769  
   770  $ podman build -f Dockerfile.in $HOME
   771  
   772  $ podman build -t imageName .
   773  
   774  $ podman build --tls-verify=true -t imageName -f Dockerfile.simple .
   775  
   776  $ podman build --tls-verify=false -t imageName .
   777  
   778  $ podman build --runtime-flag log-format=json .
   779  
   780  $ podman build --runtime-flag debug .
   781  
   782  $ podman build --authfile /tmp/auths/myauths.json --cert-dir $HOME/auth --tls-verify=true --creds=username:password -t imageName -f Dockerfile.simple .
   783  
   784  $ podman build --memory 40m --cpu-period 10000 --cpu-quota 50000 --ulimit nofile=1024:1028 -t imageName .
   785  
   786  $ podman build --security-opt label=level:s0:c100,c200 --cgroup-parent /path/to/cgroup/parent -t imageName .
   787  
   788  $ podman build --volume /home/test:/myvol:ro,Z -t imageName .
   789  
   790  $ podman build -v /var/lib/yum:/var/lib/yum:O -t imageName .
   791  
   792  $ podman build --layers -t imageName .
   793  
   794  $ podman build --no-cache -t imageName .
   795  
   796  $ podman build --layers --force-rm -t imageName .
   797  
   798  $ podman build --no-cache --rm=false -t imageName .
   799  ```
   800  
   801  ### Building an image using a URL, Git repo, or archive
   802  
   803    The build context directory can be specified as a URL to a Containerfile, a
   804  Git repository, or URL to an archive. If the URL is a Containerfile, it is
   805  downloaded to a temporary location and used as the context. When a Git
   806  repository is set as the URL, the repository is cloned locally to a temporary
   807  location and then used as the context. Lastly, if the URL is an archive, it is
   808  downloaded to a temporary location and extracted before being used as the
   809  context.
   810  
   811  #### Building an image using a URL to a Containerfile
   812  
   813    Podman will download the Containerfile to a temporary location and then use
   814  it as the build context.
   815  
   816  ```
   817  $ podman build https://10.10.10.1/podman/Containerfile
   818  ```
   819  
   820  #### Building an image using a Git repository
   821  
   822    Podman will clone the specified GitHub repository to a temporary location and
   823  use it as the context. The Containerfile at the root of the repository will be
   824  used and it only works if the GitHub repository is a dedicated repository.
   825  
   826  ```
   827  $ podman build git://github.com/scollier/purpletest
   828  ```
   829  
   830  #### Building an image using a URL to an archive
   831  
   832    Podman will fetch the archive file, decompress it, and use its contents as the
   833  build context. The Containerfile at the root of the archive and the rest of the
   834  archive will get used as the context of the build. If you pass
   835  `-f PATH/Containerfile` option as well, the system will look for that file
   836  inside the contents of the archive.
   837  
   838  ```
   839  $ podman build -f dev/Containerfile https://10.10.10.1/podman/context.tar.gz
   840  ```
   841  
   842    Note: supported compression formats are 'xz', 'bzip2', 'gzip' and 'identity'
   843  (no compression).
   844  
   845  ## Files
   846  
   847  ### `.dockerignore`
   848  
   849  If the file .dockerignore exists in the context directory, `podman build` reads
   850  its contents. Podman uses the content to exclude files and directories from
   851  the context directory, when executing COPY and ADD directives in the
   852  Containerfile/Dockerfile
   853  
   854  Users can specify a series of Unix shell globals in a .dockerignore file to
   855  identify files/directories to exclude.
   856  
   857  Podman supports a special wildcard string `**` which matches any number of
   858  directories (including zero). For example, **/*.go will exclude all files that
   859  end with .go that are found in all directories.
   860  
   861  Example .dockerignore file:
   862  
   863  ```
   864  # exclude this content for image
   865  */*.c
   866  **/output*
   867  src
   868  ```
   869  
   870  `*/*.c`
   871  Excludes files and directories whose names ends with .c in any top level
   872  subdirectory. For example, the source file include/rootless.c.
   873  
   874  `**/output*`
   875  Excludes files and directories starting with `output` from any directory.
   876  
   877  `src`
   878  Excludes files named src and the directory src as well as any content in it.
   879  
   880  Lines starting with ! (exclamation mark) can be used to make exceptions to
   881  exclusions. The following is an example .dockerignore file that uses this
   882  mechanism:
   883  ```
   884  *.doc
   885  !Help.doc
   886  ```
   887  
   888  Exclude all doc files except Help.doc from the image.
   889  
   890  This functionality is compatible with the handling of .dockerignore files
   891  described here:
   892  
   893  https://docs.docker.com/engine/reference/builder/#dockerignore-file
   894  
   895  **registries.conf** (`/etc/containers/registries.conf`)
   896  
   897  registries.conf is the configuration file which specifies which container
   898  registries should be consulted when completing image names which do not include
   899  a registry or domain portion.
   900  
   901  ## Troubleshooting
   902  
   903  ### lastlog sparse file
   904  
   905  If you are using a useradd command within a Containerfile with a large UID/GID,
   906  it will create a large sparse file `/var/log/lastlog`.  This can cause the
   907  build to hang forever.  Go language does not support sparse files correctly,
   908  which can lead to some huge files being created in your container image.
   909  
   910  If you are using `useradd` within your build script, you should pass the
   911  `--no-log-init or -l` option to the `useradd` command.  This option tells
   912  useradd to stop creating the lastlog file.
   913  
   914  ## SEE ALSO
   915  podman(1), buildah(1), containers-registries.conf(5), crun(8), runc(8), useradd(8), podman-ps(1), podman-rm(1)
   916  
   917  ## HISTORY
   918  Aug 2020, Additional options and .dockerignore added by Dan Walsh <dwalsh@redhat.com>
   919  
   920  May 2018, Minor revisions added by Joe Doss <joe@solidadmin.com>
   921  
   922  December 2017, Originally compiled by Tom Sweeney <tsweeney@redhat.com>
   923  
   924  ## FOOTNOTES
   925  <a name="Footnote1">1</a>: The Podman project is committed to inclusivity, a
   926  core value of open source. The `master` and `slave` mount propagation
   927  terminology used here is problematic and divisive, and should be changed.
   928  However, these terms are currently used within the Linux kernel and must be
   929  used as-is at this time. When the kernel maintainers rectify this usage,
   930  Podman will follow suit immediately.