github.com/containers/podman/v5@v5.1.0-rc1/docs/source/markdown/podman-build.1.md.in (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
    16  either '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  When invoked with `-f` and a path to a Containerfile, with no explicit CONTEXT
    22  directory, Podman uses the Containerfile's parent directory as its build context.
    23  
    24  Containerfiles ending with a ".in" suffix are 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. Containerfiles ending in .in are
    27  restricted to no comment lines unless they are CPP commands.
    28  Note, a Containerfile.in file can still be used by other tools when manually
    29  preprocessing them via `cpp -E`.
    30  
    31  When the URL is an archive, the contents of the URL is downloaded to a temporary
    32  location and extracted before execution.
    33  
    34  When the URL is a Containerfile, the Containerfile is downloaded to a temporary
    35  location.
    36  
    37  When a Git repository is set as the URL, the repository is cloned locally and
    38  then set as the context.  A URL is treated as a Git repository if it
    39  has a `git://` prefix or a `.git` suffix.
    40  
    41  NOTE: `podman build` uses code sourced from the `Buildah` project to build
    42  container images.  This `Buildah` code creates `Buildah` containers for the
    43  `RUN` options in container storage. In certain situations, when the
    44  `podman build` crashes or users kill the `podman build` process, these external
    45  containers can be left in container storage. Use the `podman ps --all --storage`
    46  command to see these containers. External containers can be removed with the
    47  `podman rm --storage` command.
    48  
    49  `podman buildx build` command is an alias of `podman build`.  Not all `buildx build` features are available in Podman. The `buildx build` option is provided for scripting compatibility.
    50  
    51  ## OPTIONS
    52  
    53  @@option add-host
    54  
    55  #### **--all-platforms**
    56  
    57  Instead of building for a set of platforms specified using the **--platform** option, inspect the build's base images, and build for all of the platforms for which they are all available.  Stages that use *scratch* as a starting point can not be inspected, so at least one non-*scratch* stage must be present for detection to work usefully.
    58  
    59  @@option annotation.image
    60  
    61  #### **--arch**=*arch*
    62  
    63  Set the architecture of the image to be built, and that of the base image to be
    64  pulled, if the build uses one, to the provided value instead of using the
    65  architecture of the build host. Unless overridden, subsequent lookups of the
    66  same image in the local storage matches this architecture, regardless of the
    67  host. (Examples: arm, arm64, 386, amd64, ppc64le, s390x)
    68  
    69  @@option authfile
    70  
    71  @@option build-arg
    72  
    73  @@option build-arg-file
    74  
    75  @@option build-context
    76  
    77  @@option cache-from
    78  
    79  @@option cache-to
    80  
    81  @@option cache-ttl
    82  
    83  @@option cap-add.image
    84  
    85  @@option cap-drop.image
    86  
    87  @@option cert-dir
    88  
    89  @@option cgroup-parent
    90  
    91  @@option cgroupns.image
    92  
    93  #### **--compress**
    94  
    95  This option is added to be aligned with other containers CLIs.
    96  Podman doesn't communicate with a daemon or a remote server.
    97  Thus, compressing the data before sending it is irrelevant to Podman. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
    98  
    99  @@option cpp-flag
   100  
   101  @@option cpu-period
   102  
   103  @@option cpu-quota
   104  
   105  @@option cpu-shares
   106  
   107  @@option cpuset-cpus
   108  
   109  @@option cpuset-mems
   110  
   111  @@option creds
   112  
   113  #### **--cw**=*options*
   114  
   115  Produce an image suitable for use as a confidential workload running in a
   116  trusted execution environment (TEE) using krun (i.e., *crun* built with the
   117  libkrun feature enabled and invoked as *krun*).  Instead of the conventional
   118  contents, the root filesystem of the image will contain an encrypted disk image
   119  and configuration information for krun.
   120  
   121  The value for *options* is a comma-separated list of key=value pairs, supplying
   122  configuration information which is needed for producing the additional data
   123  which will be included in the container image.
   124  
   125  Recognized _keys_ are:
   126  
   127  *attestation_url*: The location of a key broker / attestation server.
   128  If a value is specified, the new image's workload ID, along with the passphrase
   129  used to encrypt the disk image, will be registered with the server, and the
   130  server's location will be stored in the container image.
   131  At run-time, krun is expected to contact the server to retrieve the passphrase
   132  using the workload ID, which is also stored in the container image.
   133  If no value is specified, a *passphrase* value *must* be specified.
   134  
   135  *cpus*: The number of virtual CPUs which the image expects to be run with at
   136  run-time.  If not specified, a default value will be supplied.
   137  
   138  *firmware_library*: The location of the libkrunfw-sev shared library.  If not
   139  specified, `buildah` checks for its presence in a number of hard-coded
   140  locations.
   141  
   142  *memory*: The amount of memory which the image expects to be run with at
   143  run-time, as a number of megabytes.  If not specified, a default value will be
   144  supplied.
   145  
   146  *passphrase*: The passphrase to use to encrypt the disk image which will be
   147  included in the container image.
   148  If no value is specified, but an *attestation_url* value is specified, a
   149  randomly-generated passphrase will be used.
   150  The authors recommend setting an *attestation_url* but not a *passphrase*.
   151  
   152  *slop*: Extra space to allocate for the disk image compared to the size of the
   153  container image's contents, expressed either as a percentage (..%) or a size
   154  value (bytes, or larger units if suffixes like KB or MB are present), or a sum
   155  of two or more such specifications.  If not specified, `buildah` guesses that
   156  25% more space than the contents will be enough, but this option is provided in
   157  case its guess is wrong.
   158  
   159  *type*: The type of trusted execution environment (TEE) which the image should
   160  be marked for use with.  Accepted values are "SEV" (AMD Secure Encrypted
   161  Virtualization - Encrypted State) and "SNP" (AMD Secure Encrypted
   162  Virtualization - Secure Nested Paging).  If not specified, defaults to "SNP".
   163  
   164  *workload_id*: A workload identifier which will be recorded in the container
   165  image, to be used at run-time for retrieving the passphrase which was used to
   166  encrypt the disk image.  If not specified, a semi-random value will be derived
   167  from the base image's image ID.
   168  
   169  This option is not supported on the remote client, including Mac and Windows
   170  (excluding WSL2) machines.
   171  
   172  
   173  @@option decryption-key
   174  
   175  @@option device
   176  
   177  Note: if the user only has access rights via a group, accessing the device
   178  from inside a rootless container fails. The **[crun(1)](https://github.com/containers/crun/tree/main/crun.1.md)** runtime offers a
   179  workaround for this by adding the option
   180  **--annotation run.oci.keep_original_groups=1**.
   181  
   182  @@option disable-compression
   183  
   184  @@option disable-content-trust
   185  
   186  @@option dns
   187  
   188  This option cannot be combined with **--network** that is set to **none**.
   189  
   190  Note: this option takes effect only during *RUN* instructions in the build.
   191  It does not affect _/etc/resolv.conf_ in the final image.
   192  
   193  @@option dns-option.image
   194  
   195  @@option dns-search.image
   196  
   197  @@option env.image
   198  
   199  @@option file
   200  
   201  @@option force-rm
   202  
   203  @@option format
   204  
   205  @@option from
   206  
   207  @@option group-add
   208  
   209  @@option help
   210  
   211  @@option hooks-dir
   212  
   213  @@option http-proxy
   214  
   215  @@option identity-label
   216  
   217  @@option ignorefile
   218  
   219  @@option iidfile
   220  
   221  @@option ipc.image
   222  
   223  @@option isolation
   224  
   225  @@option jobs
   226  
   227  @@option label.image
   228  
   229  @@option layer-label
   230  
   231  @@option layers
   232  
   233  @@option logfile
   234  
   235  #### **--logsplit**=*bool-value*
   236  
   237  If `--logfile` and `--platform` are specified, the `--logsplit` option allows
   238  end-users to split the log file for each platform into different files in the
   239  following format: `${logfile}_${platform-os}_${platform-arch}`.
   240  This option is not supported on the remote client, including Mac and Windows
   241  (excluding WSL2) machines.
   242  
   243  @@option manifest
   244  
   245  @@option memory
   246  
   247  @@option memory-swap
   248  
   249  @@option network.image
   250  
   251  @@option no-cache
   252  
   253  @@option no-hostname
   254  
   255  @@option no-hosts
   256  
   257  This option conflicts with **--add-host**.
   258  
   259  @@option omit-history
   260  
   261  @@option os
   262  
   263  @@option os-feature
   264  
   265  @@option os-version.image
   266  
   267  #### **--output**, **-o**=*output-opts*
   268  
   269  Output destination (format: type=local,dest=path)
   270  
   271  The --output (or -o) option extends the default behavior of building a container image by allowing users to export the contents of the image as files on the local filesystem, which can be useful for generating local binaries, code generation, etc. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines)
   272  
   273  The value for --output is a comma-separated sequence of key=value pairs, defining the output type and options.
   274  
   275  Supported _keys_ are:
   276  - **dest**: Destination path for exported output. Valid value is absolute or relative path, `-` means the standard output.
   277  - **type**: Defines the type of output to be used. Valid values is documented below.
   278  
   279  Valid _type_ values are:
   280  - **local**: write the resulting build files to a directory on the client-side.
   281  - **tar**: write the resulting files as a single tarball (.tar).
   282  
   283  If no type is specified, the value defaults to **local**.
   284  Alternatively, instead of a comma-separated sequence, the value of **--output** can be just a destination (in the **dest** format) (e.g. `--output some-path`, `--output -`) where `--output some-path` is treated as if **type=local** and `--output -` is treated as if **type=tar**.
   285  
   286  @@option pid.image
   287  
   288  #### **--platform**=*os/arch[/variant][,...]*
   289  
   290  Set the *os/arch* of the built image (and its base image, when using one)
   291  to the provided value instead of using the current operating system and
   292  architecture of the host (for example `linux/arm`).  Unless overridden,
   293  subsequent lookups of the same image in the local storage matches this
   294  platform, regardless of the host.
   295  
   296  If `--platform` is set, then the values of the `--arch`, `--os`, and
   297  `--variant` options is overridden.
   298  
   299  The `--platform` option can be specified more than once, or given a
   300  comma-separated list of values as its argument.  When more than one platform is
   301  specified, the `--manifest` option is used instead of the `--tag`
   302  option.
   303  
   304  Os/arch pairs are those used by the Go Programming Language.  In several cases
   305  the *arch* value for a platform differs from one produced by other tools such as
   306  the `arch` command.  Valid OS and architecture name combinations are listed as
   307  values for $GOOS and $GOARCH at https://golang.org/doc/install/source#environment,
   308  and can also be found by running `go tool dist list`.
   309  
   310  While `podman build` is happy to use base images and build images for any
   311  platform that exists, `RUN` instructions are able to succeed without
   312  the help of emulation provided by packages like `qemu-user-static`.
   313  
   314  @@option pull.image
   315  
   316  Pull image policy. The default is **missing**.
   317  
   318  @@option quiet
   319  
   320  @@option retry
   321  
   322  @@option retry-delay
   323  
   324  @@option rm
   325  
   326  @@option runtime
   327  
   328  @@option runtime-flag
   329  
   330  #### **--sbom**=*preset*
   331  
   332  Generate SBOMs (Software Bills Of Materials) for the output image by scanning
   333  the working container and build contexts using the named combination of scanner
   334  image, scanner commands, and merge strategy.  Must be specified with one or
   335  more of **--sbom-image-output**, **--sbom-image-purl-output**, **--sbom-output**,
   336  and **--sbom-purl-output**.  Recognized presets, and the set of options which
   337  they equate to:
   338  
   339   - "syft", "syft-cyclonedx":
   340       --sbom-scanner-image=ghcr.io/anchore/syft
   341       --sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output cyclonedx-json={OUTPUT}"
   342       --sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output cyclonedx-json={OUTPUT}"
   343       --sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
   344   - "syft-spdx":
   345       --sbom-scanner-image=ghcr.io/anchore/syft
   346       --sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output spdx-json={OUTPUT}"
   347       --sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output spdx-json={OUTPUT}"
   348       --sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
   349   - "trivy", "trivy-cyclonedx":
   350       --sbom-scanner-image=ghcr.io/aquasecurity/trivy
   351       --sbom-scanner-command="trivy filesystem -q {ROOTFS} --format cyclonedx --output {OUTPUT}"
   352       --sbom-scanner-command="trivy filesystem -q {CONTEXT} --format cyclonedx --output {OUTPUT}"
   353       --sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
   354   - "trivy-spdx":
   355       --sbom-scanner-image=ghcr.io/aquasecurity/trivy
   356       --sbom-scanner-command="trivy filesystem -q {ROOTFS} --format spdx-json --output {OUTPUT}"
   357       --sbom-scanner-command="trivy filesystem -q {CONTEXT} --format spdx-json --output {OUTPUT}"
   358       --sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
   359  
   360  #### **--sbom-image-output**=*path*
   361  
   362  When generating SBOMs, store the generated SBOM in the specified path in the
   363  output image.  There is no default.
   364  
   365  #### **--sbom-image-purl-output**=*path*
   366  
   367  When generating SBOMs, scan them for PURL ([package
   368  URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
   369  information, and save a list of found PURLs to the specified path in the output
   370  image.  There is no default.
   371  
   372  #### **--sbom-merge-strategy**=*method*
   373  
   374  If more than one **--sbom-scanner-command** value is being used, use the
   375  specified method to merge the output from later commands with output from
   376  earlier commands.  Recognized values include:
   377  
   378   - cat
   379       Concatenate the files.
   380   - merge-cyclonedx-by-component-name-and-version
   381       Merge the "component" fields of JSON documents, ignoring values from
   382       documents when the combination of their "name" and "version" values is
   383       already present.  Documents are processed in the order in which they are
   384       generated, which is the order in which the commands that generate them
   385       were specified.
   386   - merge-spdx-by-package-name-and-versioninfo
   387       Merge the "package" fields of JSON documents, ignoring values from
   388       documents when the combination of their "name" and "versionInfo" values is
   389       already present.  Documents are processed in the order in which they are
   390       generated, which is the order in which the commands that generate them
   391       were specified.
   392  
   393  #### **--sbom-output**=*file*
   394  
   395  When generating SBOMs, store the generated SBOM in the named file on the local
   396  filesystem.  There is no default.
   397  
   398  #### **--sbom-purl-output**=*file*
   399  
   400  When generating SBOMs, scan them for PURL ([package
   401  URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
   402  information, and save a list of found PURLs to the named file in the local
   403  filesystem.  There is no default.
   404  
   405  #### **--sbom-scanner-command**=*image*
   406  
   407  Generate SBOMs by running the specified command from the scanner image.  If
   408  multiple commands are specified, they are run in the order in which they are
   409  specified.  These text substitutions are performed:
   410    - {ROOTFS}
   411        The root of the built image's filesystem, bind mounted.
   412    - {CONTEXT}
   413        The build context and additional build contexts, bind mounted.
   414    - {OUTPUT}
   415        The name of a temporary output file, to be read and merged with others or copied elsewhere.
   416  
   417  #### **--sbom-scanner-image**=*image*
   418  
   419  Generate SBOMs using the specified scanner image.
   420  
   421  @@option secret.image
   422  
   423  @@option security-opt.image
   424  
   425  @@option shm-size
   426  
   427  #### **--sign-by**=*fingerprint*
   428  
   429  Sign the image using a GPG key with the specified FINGERPRINT. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines,)
   430  
   431  @@option skip-unused-stages
   432  
   433  @@option squash
   434  
   435  @@option squash-all
   436  
   437  @@option ssh
   438  
   439  #### **--stdin**
   440  
   441  Pass stdin into the RUN containers. Sometime commands being RUN within a Containerfile
   442  want to request information from the user. For example apt asking for a confirmation for install.
   443  Use --stdin to be able to interact from the terminal during the build.
   444  
   445  @@option tag
   446  
   447  @@option target
   448  
   449  @@option timestamp
   450  
   451  @@option tls-verify
   452  
   453  @@option ulimit.image
   454  
   455  @@option unsetenv.image
   456  
   457  @@option unsetlabel
   458  
   459  @@option userns.image
   460  
   461  @@option userns-gid-map
   462  
   463  @@option userns-gid-map-group
   464  
   465  @@option userns-uid-map
   466  
   467  @@option userns-uid-map-user
   468  
   469  @@option uts
   470  
   471  #### **--variant**=*variant*
   472  
   473  Set the architecture variant of the image to be built, and that of the base
   474  image to be pulled, if the build uses one, to the provided value instead of
   475  using the architecture variant of the build host.
   476  
   477  @@option volume.image
   478  
   479  ## EXAMPLES
   480  
   481  ### Build an image using local Containerfiles
   482  
   483  Build image using Containerfile with content from current directory:
   484  ```
   485  $ podman build .
   486  ```
   487  
   488  Build image using specified Containerfile with content from current directory:
   489  ```
   490  $ podman build -f Containerfile.simple .
   491  ```
   492  
   493  Build image using Containerfile from stdin with content from current directory:
   494  ```
   495  $ cat $HOME/Containerfile | podman build -f - .
   496  ```
   497  
   498  Build image using multiple Containerfiles with content from current directory:
   499  ```
   500  $ podman build -f Containerfile.simple -f Containerfile.notsosimple .
   501  ```
   502  
   503  Build image with specified Containerfile with content from $HOME directory. Note `cpp` is applied to Containerfile.in before processing as Containerfile:
   504  ```
   505  $ podman build -f Containerfile.in $HOME
   506  ```
   507  
   508  Build image with the specified tag with Containerfile and content from current directory:
   509  ```
   510  $ podman build -t imageName .
   511  ```
   512  
   513  Build image ignoring registry verification for any images pulled via the Containerfile:
   514  ```
   515  $ podman build --tls-verify=false -t imageName .
   516  ```
   517  
   518  Build image with the specified logging format:
   519  ```
   520  $ podman build --runtime-flag log-format=json .
   521  ```
   522  
   523  Build image using debug mode for logging:
   524  ```
   525  $ podman build --runtime-flag debug .
   526  ```
   527  
   528  Build image using specified registry attributes when pulling images from the selected Containerfile:
   529  ```
   530  $ podman build --authfile /tmp/auths/myauths.json --cert-dir $HOME/auth --tls-verify=true --creds=username:password -t imageName -f Containerfile.simple .
   531  ```
   532  
   533  Build image using specified resource controls when running containers during the build:
   534  ```
   535  $ podman build --memory 40m --cpu-period 10000 --cpu-quota 50000 --ulimit nofile=1024:1028 -t imageName .
   536  ```
   537  
   538  Build image using specified SELinux labels and cgroup config running containers during the build:
   539  ```
   540  $ podman build --security-opt label=level:s0:c100,c200 --cgroup-parent /path/to/cgroup/parent -t imageName .
   541  ```
   542  
   543  Build image with read-only and SELinux relabeled volume mounted from the host into running containers during the build:
   544  ```
   545  $ podman build --volume /home/test:/myvol:ro,Z -t imageName .
   546  ```
   547  
   548  Build image with overlay volume mounted from the host into running containers during the build:
   549  ```
   550  $ podman build -v /var/lib/yum:/var/lib/yum:O -t imageName .
   551  ```
   552  
   553  Build image using layers and then removing intermediate containers even if the build fails.
   554  ```
   555  $ podman build --layers --force-rm -t imageName .
   556  ```
   557  
   558  Build image ignoring cache and not removing intermediate containers even if the build succeeds:
   559  ```
   560  $ podman build --no-cache --rm=false -t imageName .
   561  ```
   562  
   563  Build image using the specified network when running containers during the build:
   564  ```
   565  $ podman build --network mynet .
   566  ```
   567  
   568  ### Building a multi-architecture image using the --manifest option (requires emulation software)
   569  
   570  Build image using the specified architectures and link to a single manifest on successful completion:
   571  ```
   572  $ podman build --arch arm --manifest myimage /tmp/mysrc
   573  $ podman build --arch amd64 --manifest myimage /tmp/mysrc
   574  $ podman build --arch s390x --manifest myimage /tmp/mysrc
   575  ```
   576  
   577  Similarly build using a single command
   578  ```
   579  $ podman build --platform linux/s390x,linux/ppc64le,linux/amd64 --manifest myimage /tmp/mysrc
   580  ```
   581  
   582  Build image using multiple specified architectures and link to single manifest on successful completion:
   583  ```
   584  $ podman build --platform linux/arm64 --platform linux/amd64 --manifest myimage /tmp/mysrc
   585  ```
   586  
   587  ### Building an image using a URL, Git repo, or archive
   588  
   589    The build context directory can be specified as a URL to a Containerfile, a
   590  Git repository, or URL to an archive. If the URL is a Containerfile, it is
   591  downloaded to a temporary location and used as the context. When a Git
   592  repository is set as the URL, the repository is cloned locally to a temporary
   593  location and then used as the context. Lastly, if the URL is an archive, it is
   594  downloaded to a temporary location and extracted before being used as the
   595  context.
   596  
   597  #### Building an image using a URL to a Containerfile
   598  
   599  Build image from Containerfile downloaded into temporary location used as the build context:
   600  ```
   601  $ podman build https://10.10.10.1/podman/Containerfile
   602  ```
   603  
   604  #### Building an image using a Git repository
   605  
   606    Podman clones the specified GitHub repository to a temporary location and
   607  use it as the context. The Containerfile at the root of the repository is used
   608  and it only works if the GitHub repository is a dedicated repository.
   609  
   610  Build image from specified git repository downloaded into temporary location used as the build context:
   611  ```
   612  $ podman build -t hello  https://github.com/containers/PodmanHello.git
   613  $ podman run hello
   614  ```
   615  
   616    Note: GitHub does not support using `git://` for performing `clone` operation due to recent changes in their security guidance (https://github.blog/2021-09-01-improving-git-protocol-security-github/). Use an `https://` URL if the source repository is hosted on GitHub.
   617  
   618  #### Building an image using a URL to an archive
   619  
   620    Podman fetches the archive file, decompress it, and use its contents as the
   621  build context. The Containerfile at the root of the archive and the rest of the
   622  archive are used as the context of the build. Passing the
   623  `-f PATH/Containerfile` option as well tells the system to look for that file
   624  inside the contents of the archive.
   625  
   626  ```
   627  $ podman build -f dev/Containerfile https://10.10.10.1/podman/context.tar.gz
   628  ```
   629  
   630    Note: supported compression formats are 'xz', 'bzip2', 'gzip' and 'identity'
   631  (no compression).
   632  
   633  ## Files
   634  
   635  ### .containerignore/.dockerignore
   636  
   637  If the file *.containerignore* or *.dockerignore* exists in the context directory,
   638  `podman build` reads its contents. Use the `--ignorefile` option to override the
   639  .containerignore path location.
   640  Podman uses the content to exclude files and directories from the context
   641  directory, when executing COPY and ADD directives in the
   642  Containerfile/Dockerfile
   643  
   644  The .containerignore and .dockerignore files use the same syntax; if both
   645  are in the context directory, podman build only uses .containerignore.
   646  
   647  Users can specify a series of Unix shell globs in a .containerignore file to
   648  identify files/directories to exclude.
   649  
   650  Podman supports a special wildcard string `**` which matches any number of
   651  directories (including zero). For example, **/*.go excludes all files that
   652  end with .go that are found in all directories.
   653  
   654  Example .containerignore file:
   655  
   656  ```
   657  # exclude this content for image
   658  */*.c
   659  **/output*
   660  src
   661  ```
   662  
   663  `*/*.c`
   664  Excludes files and directories whose names ends with .c in any top level
   665  subdirectory. For example, the source file include/rootless.c.
   666  
   667  `**/output*`
   668  Excludes files and directories starting with `output` from any directory.
   669  
   670  `src`
   671  Excludes files named src and the directory src as well as any content in it.
   672  
   673  Lines starting with ! (exclamation mark) can be used to make exceptions to
   674  exclusions. The following is an example .containerignore file that uses this
   675  mechanism:
   676  ```
   677  *.doc
   678  !Help.doc
   679  ```
   680  
   681  Exclude all doc files except Help.doc from the image.
   682  
   683  This functionality is compatible with the handling of .containerignore files
   684  described here:
   685  
   686  https://github.com/containers/common/blob/main/docs/containerignore.5.md
   687  
   688  **registries.conf** (`/etc/containers/registries.conf`)
   689  
   690  registries.conf is the configuration file which specifies which container
   691  registries is consulted when completing image names which do not include
   692  a registry or domain portion.
   693  
   694  ## Troubleshooting
   695  
   696  ### lastlog sparse file
   697  
   698  Using a useradd command within a Containerfile with a large UID/GID creates
   699  a large sparse file `/var/log/lastlog`.  This can cause the
   700  build to hang forever.  Go language does not support sparse files correctly,
   701  which can lead to some huge files being created in the container image.
   702  
   703  When using the `useradd` command within the build script, pass the
   704  `--no-log-init or -l` option to the `useradd` command.  This option tells
   705  useradd to stop creating the lastlog file.
   706  
   707  ## SEE ALSO
   708  **[podman(1)](podman.1.md)**, **[buildah(1)](https://github.com/containers/buildah/blob/main/docs/buildah.1.md)**, **[containers-certs.d(5)](https://github.com/containers/image/blob/main/docs/containers-certs.d.5.md)**, **[containers-registries.conf(5)](https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md)**, **[crun(1)](https://github.com/containers/crun/blob/main/crun.1.md)**, **[runc(8)](https://github.com/opencontainers/runc/blob/main/man/runc.8.md)**, **[useradd(8)](https://www.unix.com/man-page/redhat/8/useradd)**, **[podman-ps(1)](podman-ps.1.md)**, **[podman-rm(1)](podman-rm.1.md)**, **[Containerfile(5)](https://github.com/containers/common/blob/main/docs/Containerfile.5.md)**, **[containerignore(5)](https://github.com/containers/common/blob/main/docs/containerignore.5.md)**
   709  
   710  ## HISTORY
   711  Aug 2020, Additional options and .containerignore added by Dan Walsh `<dwalsh@redhat.com>`
   712  
   713  May 2018, Minor revisions added by Joe Doss `<joe@solidadmin.com>`
   714  
   715  December 2017, Originally compiled by Tom Sweeney `<tsweeney@redhat.com>`
   716  
   717  ## FOOTNOTES
   718  <a name="Footnote1">1</a>: The Podman project is committed to inclusivity, a
   719  core value of open source. The `master` and `slave` mount propagation
   720  terminology used here is problematic and divisive, and needs to be changed.
   721  However, these terms are currently used within the Linux kernel and must be
   722  used as-is at this time. When the kernel maintainers rectify this usage,
   723  Podman will follow suit immediately.