podman-farm-build(1)

✨ NAME ✨

podman-farm-build β€” build images out on your farm nodes, then bundle those babies into a manifest list 🫢 (this one lives in the General Commands Manual, bestie, and it's the podman-farm-build(1) page)


🌸 SYNOPSIS 🌸

podman farm build [options] [context]

πŸ’… DESCRIPTION πŸ’…

Okay so podman farm build does the absolute most and honestly? Iconic. It builds an image on all the nodes in a farm and then bundles them all up into a manifest list ✨

Here's the vibe: it runs the podman build command on the nodes in the farm with the Containerfile you give it. Once the images are built on all the farm nodes, those images get pushed to the registry you named with the --tag flag. And once all of them have been pushed, a manifest list is created locally and pushed to the registry too πŸŽ€

That manifest list has one image per native architecture type that's present in the farm. No cap.

The whole main-character purpose of this command is to make multi-architecture builds that are faster than doing it via emulation using podman build --arch --platform. Speed slay πŸ”₯

If you don't specify a farm, the build gets sent out to all the nodes that podman system connection knows about. Surprise bestie, it's everybody πŸ“’

⚠️ Big note, don't skip this one: since the images built are directly pushed to a registry, you must pass in a full image name using the --tag option, in the format registry/repository/imageName[:tag].

πŸ¦‹ OPTIONS πŸ¦‹

--add-host

  • --add-host=hostname[;hostname[;...]]:ip β€” adds a custom host-to-IP mapping to the container's /etc/hosts file πŸ’–

So this one takes one or multiple semicolon-separated hostnames to be mapped to a single IPv4 or IPv6 address, separated by a colon. You can also use it to overwrite the IP addresses of hostnames Podman adds to /etc/hosts by default (also see the --name and --hostname options, iykyk). You can specify this option multiple times to add additional mappings to /etc/hosts. It conflicts with the --no-hosts option and it conflicts with no_hosts=true in containers.conf 🫢

Instead of an IP address, you can hand it the special flag host-gateway. That resolves to an IP address the container can use to connect to the host. The IP address chosen depends on your network setup, so there's genuinely no guarantee that Podman can determine the host-gateway address automatically β€” and if it can't, Podman fails with an error message 😭 You can overwrite this IP address using the host_containers_internal_ip option in containers.conf.

The host-gateway address is also used by Podman to automatically add the host.containers.internal and host.docker.internal hostnames to /etc/hosts. You can prevent that by either giving the --no-hosts option, or by setting host_containers_internal_ip="none" in containers.conf. If no host-gateway address was configured manually and Podman fails to determine the IP address automatically, Podman will silently skip adding these internal hostnames to /etc/hosts. And if Podman is running in a virtual machine using podman machine (this includes Mac and Windows hosts), Podman will silently skip adding the internal hostnames to /etc/hosts, unless an IP address was configured manually β€” in that case the internal hostnames are resolved by the gvproxy DNS resolver instead 🧚

By default Podman uses the /etc/hosts file of the host as a basis, i.e. any hostname present in that file will also be present in the /etc/hosts file of the container. A different base file can be configured using the base_hosts_file config in containers.conf ⭐

--annotation

  • --annotation=annotation=value β€” adds an image annotation (like annotation=value) to the image metadata. Can be used multiple times πŸ’…
πŸ™ˆ Note: this information is not present in Docker image formats, so it gets discarded when writing images in Docker formats. Gone. Poof.

--authfile

  • --authfile=path β€” path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json on Linux, and $HOME/.config/containers/auth.json on Windows/macOS. The file is created by podman login. If the authorization state isn't found there, $HOME/.docker/config.json gets checked, which is set using docker login πŸ”‘
πŸ’‘ Note: there's also the option to override the default path of the authentication file by setting the REGISTRY_AUTH_FILE environment variable. You do it like this: export REGISTRY_AUTH_FILE=path.

--build-arg

  • --build-arg=arg=value β€” specifies a build argument and its value, which gets interpolated in instructions read from the Containerfiles the same way environment variables are, but which are not added to the environment variable list in the resulting image's configuration πŸŽ€ (so it's like a secret little value for build time only, not a permanent resident)

--build-arg-file

  • --build-arg-file=path β€” specifies a file containing lines of build arguments of the form arg=value. The suggested file name is argfile.conf πŸ“„

Comment lines beginning with # are ignored, along with blank lines. All the others must be of the arg=value format passed to --build-arg.

If several arguments are provided via the --build-arg-file and --build-arg options, the build arguments are merged across all of the provided files and command line arguments.

Any file provided in a --build-arg-file option is read before the arguments supplied via the --build-arg option.

When a given argument name is specified several times, the last instance is the one that's passed to the resulting builds. Which means --build-arg values always override those in a --build-arg-file πŸ‘‘

--build-context

  • --build-context=name=value β€” specify an additional build context using its short name and its location. Additional build contexts can be referenced in the same manner as we access different stages in the COPY instruction 🌈

Valid values are:

  • Local directory – e.g. --build-context project2=../path/to/project2/src
  • HTTP URL to a tarball – e.g. --build-context src=https://example.org/releases/src.tar
  • Container image – specified with a container-image:// prefix, e.g. --build-context alpine=container-image://alpine:3.15, (also accepts docker://, docker-image://)

On the Containerfile side, reference the build context on all commands that accept the "from" parameter. Here's how that might look:

FROM [name]
COPY --from=[name] ...
RUN --mount=from=[name] …

The value of [name] is matched with the following priority order:

  1. Named build context defined with --build-context [name]=..
  2. Stage defined with AS [name] inside Containerfile
  3. Image [name], either local or in a remote registry

--cache-from

  • --cache-from=image β€” repository to utilize as a potential cache source. When specified, Buildah tries to look for cache images in the specified repository and attempts to pull cache images instead of actually executing the build steps locally. Buildah only attempts to pull previously cached images if they're considered as valid cache hits πŸ’–

Use the --cache-to option to populate a remote repository with cache content.

Example:

# populate a cache and also consult it
buildah build -t test --layers --cache-to registry/myrepo/cache --cache-from registry/myrepo/cache .
⚠️ Note: the --cache-from option is ignored unless --layers is specified. Don't forget it bestie.

--cache-to

  • --cache-to=image β€” set this flag to specify a remote repository that's used to store cache images. Buildah attempts to push newly built cache images to the remote repository 🎯
πŸ’‘ Note: use the --cache-from option in order to use cache content in a remote repository.

Example:

# populate a cache and also consult it
buildah build -t test --layers --cache-to registry/myrepo/cache --cache-from registry/myrepo/cache .
⚠️ Note: the --cache-to option is ignored unless --layers is specified.

--cache-ttl

  • --cache-ttl β€” limit the use of cached images to only consider images with created timestamps less than duration ago ⏳ For example, if --cache-ttl=1h is specified, Buildah considers intermediate cache images which are created under the duration of one hour, and intermediate cache images outside this duration get ignored.
πŸ’€ Note: setting --cache-ttl=0 manually is equivalent to using --no-cache in the implementation, since this means the user does not want to use cache at all. Zero means zero.

--cap-add

  • --cap-add=CAP_xxx β€” when executing RUN instructions, run the command specified in the instruction with the specified capability added to its capability set. Certain capabilities are granted by default; this option can be used to add more πŸ”₯

--cap-drop

  • --cap-drop=CAP_xxx β€” when executing RUN instructions, run the command specified in the instruction with the specified capability removed from its capability set πŸ’… The CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_FOWNER, CAP_FSETID, CAP_KILL, CAP_NET_BIND_SERVICE, CAP_SETFCAP, CAP_SETGID, CAP_SETPCAP, and CAP_SETUID capabilities are granted by default; this option can be used to remove them.

If a capability is specified to both the --cap-add and --cap-drop options, it gets dropped, regardless of the order in which the options were given. Sorry bestie, drop wins 🫠

--cert-dir

  • --cert-dir=path β€” use certificates at path (*.crt, *.cert, *.key) to connect to the registry. (Default: /etc/containers/certs.d) For details, see containers-certs.d(5) πŸ“œ (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines.)

--cgroup-parent

  • --cgroup-parent=path β€” path to cgroups under which the cgroup for the container is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups are created if they don't already exist 🌱

--cgroupns

  • --cgroupns=how β€” sets the configuration for cgroup namespaces when handling RUN instructions πŸŽ€ The configured value can be "" (the empty string) or "private" to indicate that a new cgroup namespace is created, or it can be "host" to indicate that the cgroup namespace in which buildah itself is being run is reused.

--cleanup

  • --cleanup β€” remove built images from farm nodes on success (Default: false). Tidy queen behaviour 🧹✨

--compat-volumes

  • --compat-volumes β€” handle directories marked using the VOLUME instruction (both in this build, and those inherited from base images) such that their contents can only be modified by ADD and COPY instructions. Any changes made in those locations by RUN instructions will be reverted πŸ™ˆ Before the introduction of this option, this behavior was the default, but it's now disabled by default. Things change, we grow.

--compression-format

  • --compression-format=gzip | zstd | zstd:chunked β€” specifies the compression format to use. Supported values are: gzip, zstd and zstd:chunked. The default is gzip unless overridden in the containers.conf file πŸ“¦ zstd:chunked is incompatible with encrypting images, and will be treated as zstd with a warning in that case.

--compression-level

  • --compression-level=level β€” specifies the compression level to use. The value is specific to the compression algorithm used, e.g. for zstd the accepted values are in the range 1-20 (inclusive) with a default of 3, while for gzip it's 1-9 (inclusive) and has a default of 5 🎚️

--cpp-flag

  • --cpp-flag=flags β€” set additional flags to pass to the C Preprocessor cpp(1) 🧚 Containerfiles ending with a .in suffix get preprocessed via cpp(1). This option can be used to pass additional flags to cpp. Note: you can also set default CPPFLAGS by setting the BUILDAH_CPPFLAGS environment variable (e.g., export BUILDAH_CPPFLAGS="-DDEBUG") πŸ’œ
  • --cpu-period=limit β€” sets the CPU period for the Completely Fair Scheduler (CFS), and that's a duration in microseconds. Once your container has burned through its CPU quota, it just... doesn't get scheduled until the current period wraps up. Defaults to 100000 microseconds. 🫢

Heads up, on some systems changing resource limits isn't allowed for non-root users β€” deets over here: https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

This option is not supported on cgroups V1 rootless systems. Not me showing up with a flag that just won't work πŸ’€
  • --cpu-quota=limit β€” caps the CPU Completely Fair Scheduler (CFS) quota, i.e. it limits how much CPU your container can use. By default containers run with the full CPU resource. The limit is a number in microseconds β€” give it a number and the container gets to use that much CPU time until the CPU period ends (and the period is controllable via --cpu-period). 🌸

Same warning as above, bestie: on some systems changing resource limits isn't allowed for non-root users. More details: https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

Not supported on cgroups V1 rootless systems. Again. 😭
  • --cpu-shares, -c=shares β€” CPU shares, aka the relative weight. πŸŽ€

By default every container gets the same proportion of CPU cycles. You can change that proportion by tweaking the container's CPU share weighting relative to the combined weight of all the running containers. Default weight is 1024.

The proportion only actually applies when CPU-intensive processes are running β€” when tasks in one container are idle, the other containers can scoop up the leftover CPU time. The actual amount of CPU time you get varies depending on how many containers are running on the system.

Example time, because this is genuinely fun: imagine three containers, one with a cpu-share of 1024 and two others with a cpu-share setting of 512. When processes in all three containers all try to use 100% of CPU, the first container receives 50% of the total CPU time. Add a fourth container with a cpu-share of 1024, and the first container now only gets 33% of the CPU. The remaining containers receive 16.5%, 16.5% and 33% of the CPU. Math ate, honestly. ✨

On a multi-core system, the shares of CPU time get distributed over all CPU cores. So even if a container is limited to less than 100% of CPU time, it can still use 100% of each individual CPU core. Wild but true.

For example, consider a system with more than three cores. If container C0 is started with --cpu-shares=512 running one process, and another container C1 with --cpu-shares=1024 running two processes, this can result in the following division of CPU shares:

β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PID β”‚ container β”‚ CPU β”‚ CPU share    β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 100 β”‚ C0        β”‚ 0   β”‚ 100% of CPU0 β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 101 β”‚ C1        β”‚ 1   β”‚ 100% of CPU1 β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 102 β”‚ C1        β”‚ 2   β”‚ 100% of CPU2 β”‚
β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

And the classic: on some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

Not supported on cgroups V1 rootless systems. πŸ’…
  • --cpuset-cpus=number β€” which CPUs you're allowed to execute on. You can give it a comma-separated list (e.g. 0,1), a range (e.g. 0-3), or any combination of the two (e.g. 0-3,7,11-15). Mix and match, queen. πŸ‘‘

On some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

Not supported on cgroups V1 rootless systems. πŸ¦‹
  • --cpuset-mems=nodes β€” the memory nodes (MEMs) you allow execution in (0-3, 0,1). Only effective on NUMA systems, so if that's not your setup, this one's kind of just vibing.

If there are four memory nodes on the system (0-3), use --cpuset-mems=0,1 and then processes in the container only use memory from the first two memory nodes. Simple as. ✨

Yep, you guessed it: on some systems, changing the resource limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error

Not supported on cgroups V1 rootless systems. 😭
  • --created-annotation β€” adds an image annotation (see also --annotation) to the image metadata, setting "org.opencontainers.image.created" to the current time, or to the datestamp you passed to the --source-date-epoch or --timestamp flag, if you used either one. If false, no such annotation will be present in the written image.
Note: this information is not present in Docker image formats, so it gets discarded when writing images in Docker formats. Gone, reduced to atoms πŸ’€
  • --creds=[username[:password]] β€” the [username[:password]] to use to authenticate with the registry, if that's required. If one or both values aren't supplied, a command line prompt pops up and you can type the value in. The password is entered without echo, so nobody's shoulder-surfing your secrets. πŸ™ˆ

Note that the specified credentials are only used to authenticate against target registries. They are not used for mirrors or when the registry gets rewritten (see containers-registries.conf(5)); to authenticate against those, consider using a containers-auth.json(5) file. iykyk 🫢

  • --decryption-key=key[:passphrase] β€” the [key[:passphrase]] used for decryption of images. The key can point to keys and/or certificates. Decryption is tried with all keys. If the key is protected by a passphrase, it's required to be passed in the argument, and omitted otherwise. No passphrase, no entry. πŸ”
  • --device=host-device[:container-device][:permissions] β€” adds a host device to the container. The format is HOST-DEVICE[:CONTAINER-DEVICE][:PERMISSIONS], where HOST-DEVICE is the path of the device node on the host, CONTAINER-DEVICE is the path of the device node in the container, and PERMISSIONS is a list of permissions combining r for read, w for write, and m for mknod(2). πŸŽ€

Example: --device=/dev/sdc:/dev/xvdc:rwm.

Note: if host-device is a symbolic link then it is resolved first. The container only stores the major and minor numbers of the host device.

Podman may load kernel modules required for using the specified device. The devices that Podman loads modules for when necessary are: /dev/fuse.

In rootless mode, the new device is bind mounted in the container from the host rather than Podman creating it within the container space. Because the bind mount retains its SELinux label on SELinux systems, the container can get permission denied when accessing the mounted device. Modify SELinux settings to allow containers to use all device labels via the following command:

$ sudo setsebool -P  container_use_devices=true
Note: if the user only has access rights via a group, accessing the device from inside a rootless container fails. The crun(1) runtime offers a workaround for this by adding the option --annotation run.oci.keep_original_groups=1. Slay, crun 🫢
  • --disable-compression, -D β€” don't compress filesystem layers when building the image, unless the location where the image is being written requires it. This is the default setting, because image layers get compressed automatically when they're pushed to registries, and images being written to local storage only need to be decompressed again to be stored anyway. Compression can be forced in all cases by specifying --disable-compression=false. πŸ’…
  • --dns=ipaddr β€” set custom DNS servers.

This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g. 127.0.0.1). When that's the case, the --dns flag is necessary for every run. Every. Single. One.

The special value none can be specified to disable creation of /etc/resolv.conf in the container by Podman. The /etc/resolv.conf file in the image is then used without changes.

Note that ipaddr may be added directly to the container's /etc/resolv.conf. This is not guaranteed though. For example, passing a custom network whose dns_enabled is set to true to --network will result in /etc/resolv.conf only referring to the aardvark-dns server. aardvark-dns then forwards to the supplied ipaddr for all non-container name queries. That's just how it goes.

This option cannot be combined with --network that is set to none.

Note: this option takes effect only during RUN instructions in the build. It does not affect /etc/resolv.conf in the final image. She's temporary, bestie 🌸
  • --dns-option=option β€” set custom DNS options to be used during the build. ✨
  • --dns-search=domain β€” set custom DNS search domains to be used during the build. ✨
  • --env=env[=value] β€” add a value (e.g. env=value) to the built image. Can be used multiple times, stack 'em up. If neither = nor a value are specified, but env is set in the current environment, the value from the current environment is added to the image. Vibes inherit, basically. πŸ¦‹

To remove an environment variable from the built image, use the --unsetenv option.

  • --farm β€” this option specifies the name of the farm to be used in the build process. πŸ‘‘

This option specifies the name of the farm to be used in the build process.

(Yeah, it's in there twice. We don't know why either. We still respect it πŸ’…)

  • --file, -f=Containerfile β€” specifies a Containerfile which contains instructions for building the image, either a local file or an http or https URL. If more than one Containerfile is specified, FROM instructions are only accepted from the last specified file. Last one wins, periodt. πŸŽ€

If a build context is not specified, and at least one Containerfile is a local file, the directory in which it resides is used as the build context.

Specifying the option -f - causes the Containerfile contents to be read from stdin. 🫢

  • --force-compression β€” if set, push uses the specified compression algorithm even if the destination already contains a differently-compressed variant. Defaults to true if --compression-format is explicitly specified on the command-line, false otherwise. No cap. πŸ”₯
  • --force-rm β€” always remove intermediate containers after a build, even if the build fails (default true). Clean up your mess, icon behaviour. ✨
  • --format β€” control the format for the built image's manifest and configuration data. Recognized formats include oci (OCI image-spec v1.0, the default) and docker (version 2, using schema format 2 for the manifest). πŸ’œ
🌈 Note bestie: you can also override the default format by setting the BUILDAH_FORMAT environment variable. Like, export BUILDAH_FORMAT=docker β€” iconic.
  • --from β€” overrides the first FROM instruction inside the Containerfile. If there are multiple FROM instructions in a Containerfile, only the first one gets changed. With the remote podman client, not all container transports work as expected β€” for example, oci-archive:/x.tar references /x.tar on the remote machine instead of on the client. When using podman remote clients it is best to restrict use to containers-storage, and docker:// transports.
  • --group-add=group, keep-groups β€” assign additional groups to the primary user running within the container process. πŸ’…
    • keep-groups is a special flag that tells Podman to keep the supplementary group access.

Allows the container to use the user's supplementary group access. If file systems or devices are only accessible by the rootless user's group, this flag tells the OCI runtime to pass the group access into the container. Currently only available with the crun OCI runtime. Note: keep-groups is exclusive, other groups cannot be specified with this flag. (Not available for remote commands, including Mac and Windows (excluding WSL2) machines)

  • --help, -h β€” print usage statement.
  • --hooks-dir=path β€” each *.json file in the path configures a hook for buildah build containers. For more details on the syntax of the JSON files and the semantics of hook injection. Buildah currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated. This option may be set multiple times; paths from later options have higher precedence. For the annotation conditions, buildah uses any annotations set in the generated OCI configuration. For the bind-mount conditions, only mounts explicitly requested by the caller via --volume are considered. Bind mounts that buildah inserts by default (e.g. /dev/shm) are not considered. If --hooks-dir is unset for root callers, Buildah currently defaults to /usr/share/containers/oci/hooks.d and /etc/containers/oci/hooks.d in order of increasing precedence. Using these defaults is deprecated. Migrate to explicitly setting --hooks-dir.
  • --http-proxy β€” by default proxy environment variables are passed into the container if set for the Podman process. This can be disabled by setting the value to false. The environment variables passed in include http_proxy, https_proxy, ftp_proxy, no_proxy, and also the upper case versions of those. This option is only needed when the host system must use a proxy but the container does not use any proxy. Proxy environment variables specified for the container in any other way overrides the values that have been passed through from the host. (Other ways to specify the proxy for the container include passing the values with the --env flag, or hard coding the proxy environment at container build time.) When used with the remote client it uses the proxy environment variables that are set on the server process. Defaults to true.
  • --identity-label β€” adds default identity label io.buildah.version if set. (default true).
  • --ignorefile β€” path to an alternative .containerignore file.
  • --iidfile=ImageIDfile β€” write the built image's ID to the file. When --platform is specified more than once, attempting to use this option triggers an error.
  • --iidfile-raw=ImageIDfile β€” write the built image's ID to the file without the algorithm prefix (e.g., sha256:). When --platform is specified more than once, attempting to use this option triggers an error.
  • --inherit-annotations=bool-value β€” inherit the annotations from the base image or base stages. (default true). Use cases which set this flag to false may need to do the same for the --created-annotation flag.
  • --inherit-labels β€” inherit the labels from the base image or base stages. (default true).
  • --ipc=how β€” sets the configuration for IPC namespaces when handling RUN instructions. The configured value can be "" (the empty string) or "container" to indicate that a new IPC namespace is created, or it can be "host" to indicate that the IPC namespace in which podman itself is being run is reused, or it can be the path to an IPC namespace which is already in use by another process.
  • --isolation=type β€” controls what type of isolation is used for running processes as part of RUN instructions. Recognized types include oci (OCI-compatible runtime, the default), rootless (OCI-compatible runtime invoked using a modified configuration and its --rootless option enabled, with --no-new-keyring --no-pivot added to its create invocation, with network and UTS namespaces disabled, and IPC, PID, and user namespaces enabled; the default for unprivileged users), and chroot (an internal wrapper that leans more toward chroot(1) than container technology).
✨ Note: you can also override the default isolation type by setting the BUILDAH_ISOLATION environment variable. export BUILDAH_ISOLATION=oci
  • --jobs=number β€” run up to N concurrent stages in parallel. If the number of jobs is greater than 1, stdin is read from /dev/null. If 0 is specified, then there is no limit in the number of jobs that run in parallel.
  • --label=label β€” add an image label (e.g. label=value) to the image metadata. Can be used multiple times. Users can set a special LABEL io.containers.capabilities=CAP1,CAP2,CAP3 in a Containerfile that specifies the list of Linux capabilities required for the container to run properly. This label specified in a container image tells Podman to run the container with just these capabilities. Podman launches the container with just the specified capabilities, as long as this list of capabilities is a subset of the default list. If the specified capabilities are not in the default set, Podman prints an error message and runs the container with the default capabilities.
  • --layer-label=label[=value] β€” add an intermediate image label (e.g. label=value) to the intermediate image metadata. It can be used multiple times. If label is named, but neither = nor a value is provided, then the label is set to an empty value.
  • --layers β€” cache intermediate images during the build process (Default is true).
πŸ’€ Note: you can also override the default value of layers by setting the BUILDAH_LAYERS environment variable. export BUILDAH_LAYERS=true
  • --local, -l β€” build image on local machine as well as on farm nodes.
  • --logfile=filename β€” log output which is sent to standard output and standard error to the specified file instead of to standard output and standard error. This option is not supported on the remote client, including Mac and Windows (excluding WSL2) machines.
  • --memory, -m=number[unit] β€” memory limit. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes). Allows the memory available to a container to be constrained. If the host supports swap memory, then the --memory memory setting can be larger than physical RAM. If a limit of 0 is specified (not using --memory), the container's memory is not limited. The actual limit may be rounded up to a multiple of the operating system's page size (the value is very large, that's millions of trillions). This option is not supported on cgroups V1 rootless systems.
  • --memory-swap=number[unit] β€” a limit value equal to memory plus swap. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes). Must be used with the -m (--memory) flag. The argument value must be larger than that of -m (--memory) By default, it is set to double the value of --memory. Set number to -1 to enable unlimited swap. This option is not supported on cgroups V1 rootless systems.
  • --mount=mount-specification β€” adds this mount to each RUN command in a Containerfile before executing. For example:
podman build --mount=type=secret,id=mysecret …

and a Containerfile entry of:

RUN cat /run/secrets/mysecret

Has the same effect as:

RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
  • --network=mode, --net β€” sets the configuration for network namespaces when handling RUN instructions. Valid mode values are:
    • none: no networking.
    • host: use the Podman host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. 🚨
    • ns:path: path to a network namespace to join.
    • private: create a new namespace for the container (default).
    • <network name|ID>: join the network with the given name or ID, e.g. use --network mynet to join the network with the name mynet. Only supported for rootful users.
    • pasta[:OPTIONS,...]: use pasta(1) to create a user-mode networking stack. This is the default for rootless containers and only supported in rootless mode. By default, IPv4 and IPv6 addresses and routes, as well as the pod interface name, are copied from the host. If port forwarding isn't configured, ports are forwarded dynamically as services are bound on either side (init namespace or container namespace). Port forwarding preserves the original source IP address. Options described in pasta(1) can be specified as comma-separated arguments. In terms of pasta(1) options, --config-net is given by default, in order to configure networking when the container is started, and --no-map-gw is also assumed by default, to avoid direct access from container to host using the gateway address. The latter can be overridden by passing --map-gw in the pasta-specific options (despite not being an actual pasta(1) option). Also, -t none and -u none are passed to disable automatic port forwarding based on bound ports. Similarly, -T none and -U none are given to disable the same functionality from container to host. Some examples:
      • pasta:--map-gw: allow the container to directly reach the host using the gateway address.
      • pasta:--mtu,1500: specify a 1500 bytes MTU for the tap interface in the container.
      • pasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp: disable IPv6, assign 10.0.2.0/24 to the tap0 interface in the container, with gateway 10.0.2.3, enable DNS forwarder reachable at 10.0.2.3, set MTU to 1500 bytes, disable NDP, DHCPv6 and DHCP support.
      • pasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp: same as above, but leave the MTU to 65520 bytes.
      • pasta:-t,auto,-u,auto,-T,auto,-U,auto: enable automatic port forwarding based on observed bound ports from both host and container sides.
  • pasta:-T,5201 β€” this one's the little baddie that forwards TCP port 5201 from the container to the host, and it uses the loopback interface instead of the tap interface so it's lowkey faster πŸš€
  • --no-cache β€” do <em>not</em> touch the cached images, bestie. Build from scratch with a whole new set of cached layers. Fresh start energy ✨
  • --no-hostname β€” don't make the /etc/hostname file in the containers.

By default Podman runs the /etc/hostname situation and adds the container's own hostname in there. But when you pass --no-hostname, the image's own /etc/hostname stays exactly as it is, unmodified, if it exists. Respect the original πŸ’…

  • --no-hosts β€” don't touch the /etc/hosts file in the container.

By default Podman takes full control of the container's /etc/hosts and adds entries for the container's name (peep the --name option) and hostname (peep --hostname), plus the internal host.containers.internal and host.docker.internal hosts, plus anything you added with --add-host. Check the --add-host option for the details. Passing --no-hosts disables all of that, so the image's /etc/hosts is kept unmodified. You can get the same global vibe by setting no_hosts=true in containers.conf.

⚠️ heads up: this option conflicts with --add-host. They cannot both be the main character.
  • --omit-history β€” omit build history info in the built image. (default false).

Genuinely useful when you, the end user, explicitly want to set --omit-history to drop the optional History from built images β€” or when you're working with images built by build tools that just don't put History info in their images in the first place 🫢

  • --os-feature=feature β€” set the name of a required operating system feature for the image being built. By default, if the image isn't based on scratch, the base image's required OS feature list is kept, if the base image specified any. This is typically only meaningful when the image's OS is Windows πŸͺŸ

If feature has a trailing -, then that feature gets removed from the set of required features listed in the image.

  • --os-version=version β€” set the exact required operating system version for the image being built. By default, if the image isn't based on scratch, the base image's required OS version is kept, if the base image specified one. Typically only meaningful when the image's OS is Windows, and it's typically set in Windows base images already, so using this option is usually unnecessary 😌
  • --pid=pid β€” sets the config for PID namespaces when handling RUN instructions. The value can be "" (the empty string) or "container" to say "make a new PID namespace", or "host" to say "reuse the PID namespace podman itself is running in", or it can be the path to a PID namespace that's already in use by another process.
  • --platforms=p1,p2,p3... β€” build only on farm nodes that match the platforms you list. Picky but make it fashion πŸ’…
  • --pull=policy β€” the pull image policy. Default is missing.
    • always: always pull the image, and throw an error if the pull fails.
    • missing: only pull the image when it's not already in the local containers storage. Throws an error if no image is found and the pull fails.
    • never: never pull the image, just use the one in local containers storage. Throws an error when no image is found.
    • newer: pull if the image on the registry is newer than the one in local containers storage. An image counts as newer when the digests are different β€” comparing timestamps is prone to errors, so don't. Pull errors get suppressed if a local image was found.
  • --quiet, -q β€” suppress the informational output messages (the ones telling you which instruction is being processed and how it's progressing). Print only the final error message or the successful completion info, like the image or container ID. Minimalist queen 🀫
  • --retry=attempts β€” how many times to retry pulling or pushing images between the registry and local storage if something fails. Default is 3.
  • --retry-delay=duration β€” how long to wait between retry attempts when pulling or pushing images between the registry and local storage if something fails. The default is to start at two seconds and then exponentially back off. When you set this value, that's the delay used, and no exponential back off happens. You're in charge now ⏳
  • --rewrite-timestamp β€” when generating new layers for the image, make sure no newly added content carries a timestamp later than the value used by the --source-date-epoch flag, if one was provided β€” by replacing any timestamps later than that value with that value. Time travel, but legal πŸ•°οΈ
  • --rm β€” remove intermediate containers after a successful build (default true).
  • --runtime=path β€” the path to an alternate OCI-compatible runtime, which gets used to run the commands specified by the RUN instruction.
πŸ“Œ Note: you can also override the default runtime by setting the BUILDAH_RUNTIME environment variable.
export BUILDAH_RUNTIME=/usr/local/bin/runc
  • --runtime-flag=flag β€” adds global flags for the container runtime. Wanna know which flags are supported? Go consult the manpages of whichever container runtime you picked, bestie.

Default runtime flags can be added in containers.conf.

πŸ“Œ Note: do <em>not</em> pass the leading -- to the flag. To pass the runc flag --log-format json to buildah build, the option you give is --runtime-flag log-format=json.
  • --save-stages β€” preserve intermediate stage images instead of removing them once the build finishes (default is false). By default Buildah removes intermediate stage images to save space; this option keeps them, which is genuinely useful for debugging multi-stage builds or for reusing those intermediate stages in later builds πŸ”₯

--save-stages can be used with --layers, and subsequent builds with --layers can use the preserved intermediate layers as cache.

When you combine it with --stage-labels, all stage images (final image included) get metadata labels so they're easier to identify and manage. Organized icon behaviour πŸŽ€

  • --sbom=preset β€” generate SBOMs (Software Bills Of Materials) for the output image by scanning the working container and build contexts using the named combo of scanner image, scanner commands, and merge strategy. Must be specified with one or more of --sbom-image-output, --sbom-image-purl-output, --sbom-output, and --sbom-purl-output. Recognized presets, and the set of options they equate to:
    • "syft", "syft-cyclonedx":
--sbom-scanner-image=ghcr.io/anchore/syft
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output cyclonedx-json={OUTPUT}"
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output cyclonedx-json={OUTPUT}"
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
  • "syft-spdx":
--sbom-scanner-image=ghcr.io/anchore/syft
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output spdx-json={OUTPUT}"
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output spdx-json={OUTPUT}"
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
  • "trivy", "trivy-cyclonedx":
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format cyclonedx --output {OUTPUT}"
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format cyclonedx --output {OUTPUT}"
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
  • "trivy-spdx":
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format spdx-json --output {OUTPUT}"
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format spdx-json --output {OUTPUT}"
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
  • --sbom-image-output=path β€” when generating SBOMs, store the generated SBOM at the path you specify inside the output image. There's no default.
  • --sbom-image-purl-output=path β€” when generating SBOMs, scan them for PURL (package URL https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst) info, and save a list of the PURLs it finds to the path you specify inside the output image. There's no default.
  • --sbom-merge-strategy=method β€” if more than one --sbom-scanner-command value is being used, use the specified method to merge the output from later commands with the output from earlier ones. Recognized values include:
    • cat β€” concatenate the files.
    • merge-cyclonedx-by-component-name-and-version β€” merge the "component" fields of JSON documents, ignoring values from documents when the combination of their "name" and "version" values is already present. Documents are processed in the order they're generated, which is the order the commands that generate them were specified in.
    • merge-spdx-by-package-name-and-versioninfo β€” merge the "package" fields of JSON documents, ignoring values from documents when the combination of their "name" and "versionInfo" values is already present. Documents are processed in the order they're generated, which is the order the commands that generate them were specified in.
  • --sbom-output=file β€” when generating SBOMs, store the generated SBOM in the named file on the local filesystem. There's no default.
  • --sbom-purl-output=file β€” when generating SBOMs, scan them for PURL (package URL https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst) info, and save a list of the PURLs it finds to the named file on the local filesystem. There's no default.
  • --sbom-scanner-command=image β€” generate SBOMs by running the specified command from the scanner image. If you give multiple commands, they run in the order you specified them. These text substitutions happen:
    • {ROOTFS} β€” the root of the built image's filesystem, bind mounted.
    • {CONTEXT} β€” the build context and additional build contexts, bind mounted.
    • {OUTPUT} β€” the name of a temporary output file, to be read and merged with others or copied elsewhere.
  • --sbom-scanner-image=image β€” generate SBOMs using the scanner image you specify. 🧚
  • --secret=id=id[,src=envOrFile][,env=ENV][,type=file | env] β€” pass secret information to be used in the Containerfile for building images in a safe way that will not end up stored in the final image, and won't be seen in other stages. The value of the secret gets read from an environment variable or file named by the id option, or named by the src option if it's specified, or from an environment variable specified by the env option. Check EXAMPLES for the vibes. The secret is mounted in the container at /run/secrets/id by default πŸ”

To actually use the secret later, use the --mount flag in a RUN instruction inside a Containerfile:

RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret

So about where that secret actually lands πŸ‘€ you can override the location inside the container using the target, dst, or destination option of the RUN --mount flag:

RUN --mount=type=secret,id=mysecret,target=/run/secrets/myothersecret
cat /run/secrets/myothersecret
Note: changing the contents of secret files will not trigger a rebuild of layers that use said secrets. πŸ’…
  • --security-opt=option β€” security options, bestie. Here’s the whole menu:
    • apparmor=unconfined β€” turn off apparmor confinement for the container.
    • apparmor=alternate-profile β€” set the apparmor confinement profile for the container.
    • label=user:USER β€” set the label user for the container processes.
    • label=role:ROLE β€” set the label role for the container processes.
    • label=type:TYPE β€” set the label process type for the container processes.
    • label=level:LEVEL β€” set the label level for the container processes.
    • label=filetype:TYPE β€” set the label file type for the container files.
    • label=disable β€” turn off label separation for the container.
    • no-new-privileges β€” disable container processes from gaining additional privileges.
    • seccomp=unconfined β€” turn off seccomp confinement for the container.
    • seccomp=profile.json β€” JSON file to be used as the seccomp filter for the container.
  • --shm-size=number[unit] β€” size of /dev/shm. A unit can be b (bytes), k (kibibytes), m (mebibytes), or g (gibibytes). If the unit is omitted, the system uses bytes. If the size is omitted, the default is 64m. When size is 0, there is no limit on the amount of memory used for IPC by the container. This option conflicts with --ipc=host. 🫢
  • --skip-unused-stages β€” skip stages in multi-stage builds which don’t affect the target stage. (Default: true). Slay, no wasted work ✨
  • --source-date-epoch=seconds β€” set the "created" timestamp for the built image to this number of seconds since the epoch (Unix time 0, i.e., 00:00:00 UTC on 1 January 1970). The default is to use the value set in the SOURCE_DATE_EPOCH environment variable, or the current time if it is not set. πŸ•°οΈ

The "created" timestamp is written into the image’s configuration and manifest when the image is committed, so running the same build two different times will ordinarily produce images with different sha256 hashes, even if no other changes were made to the Containerfile and build context.

When this flag is set, a SOURCE_DATE_EPOCH build arg will provide its value for a stage in which it is declared.

When this flag is set, the image configuration’s "created" timestamp is always set to the time specified, which should allow for identical images to be built at different times using the same set of inputs.

When this flag is set, output written as specified to the --output flag will bear exactly the specified timestamp.

Conflicts with the similar --timestamp flag, which also sets its specified time on the contents of new layers. ⚠️

  • --source-policy-file=pathname β€” specifies the path to a BuildKit-compatible source policy JSON file. When specified, source references (e.g., base images in FROM instructions) are evaluated against the policy rules before being used.

Source policies allow controlling which images can be used as base images and optionally converting image references (e.g., pinning tags to specific digests) without modifying Containerfiles. This is useful for enforcing organizational policies and ensuring build reproducibility. πŸŽ€

The policy file is a JSON document containing an array of rules. Each rule has:

  • action β€” the action to take when the rule matches. Valid actions are:
    • ALLOW β€” explicitly allow the source (no transformation).
    • DENY β€” block the source and fail the build.
    • CONVERT β€” transform the source to a different reference specified in updates.
  • selector β€” specifies which sources the rule applies to.
    • identifier β€” the source identifier to match (e.g., docker-image://docker.io/library/alpine:latest).
    • matchType β€” how to match the identifier. Valid types are EXACT and WILDCARD (supports * and ? glob patterns). Defaults to WILDCARD if not specified.
  • updates β€” for CONVERT actions, specifies the replacement identifier.

Rules are evaluated in order; the first matching rule wins. If no rule matches, the source is allowed by default. πŸ‘‘

Note: source policy CONVERT rules are processed after --build-context substitutions but before any substitutions specified in containers-registries.conf(5). This provides multiple ways to override which base image is used for a particular stage, in order of precedence: --build-context, then source policy, then registries.conf.

Example policy file that pins alpine:latest to a specific digest:

{
  "rules": [
    {
      "action": "CONVERT",
      "selector": {
        "identifier": "docker-image://docker.io/library/alpine:latest"
      },
      "updates": {
        "identifier": "docker-image://docker.io/library/alpine@sha256:..."
      }
    }
  ]
}

Example policy file that denies all ubuntu images:

{
  "rules": [
    {
      "action": "DENY",
      "selector": {
        "identifier": "docker-image://docker.io/library/ubuntu:*",
        "matchType": "WILDCARD"
      }
    }
  ]
}
  • --squash β€” squash all of the image’s new layers into a single new layer; any preexisting layers are not squashed. 🧚
  • --squash-all β€” squash all of the new image’s layers (including those inherited from a base image) into a single new layer. πŸ’…
  • --ssh=default | id[=socket> β€” SSH agent socket or keys to expose to the build. The socket path can be left empty to use the value of default=$SSH_AUTH_SOCK.

To later use the ssh agent, use the --mount option in a RUN instruction within a Containerfile:

RUN --mount=type=ssh,id=id mycmd
  • --stage-labels β€” add metadata labels to all intermediate stage images of the multistage build, including the final image (Default is false). This option requires --save-stages to be enabled.

When enabled, all intermediate stage images and final image will be labeled with:

  • io.buildah.stage.name β€” the stage alias (from FROM ... AS alias), or stage position if no alias is specified.
  • io.buildah.stage.base β€” the base image used by this stage (pullspec or image ID when stage uses another stage as base).

These labels make it easier to identify, query, and manage images from multi-stage builds. 🌈

  • --tag, -t=imageName β€” specifies the name which is assigned to the resulting image if the build process completes successfully. If imageName does not include a registry name, the registry name localhost is prepended to the image name. 🏷️
  • --target=stageName β€” set the target build stage to build. When building a Containerfile with multiple build stages, --target can be used to specify an intermediate build stage by name as the final stage for the resulting image. Commands after the target stage is skipped. 🎯
  • --timestamp=seconds β€” set the create timestamp to seconds since epoch to allow for deterministic builds (defaults to current time). By default, the created timestamp is changed and written into the image manifest with every commit, causing the image’s sha256 hash to be different even if the sources are exactly the same otherwise. When --timestamp is set, the created timestamp is always set to the time specified and therefore not changed, allowing the image’s sha256 hash to remain the same. All files committed to the layers of the image is created with the timestamp.

If the only instruction in a Containerfile is FROM, this flag has no effect. ⏱️

  • --tls-verify β€” require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, TLS verification is used. If set to false, TLS verification is not used. If not specified, TLS verification is used unless the target registry is listed as an insecure registry in containers-registries.conf(5). πŸ”
  • --ulimit=type=soft-limit[:hard-limit] β€” specifies resource limits to apply to processes launched when processing RUN instructions. This option can be specified multiple times. Recognized resource types include:
    • "core" β€” maximum core dump size (ulimit -c)
    • "cpu" β€” maximum CPU time (ulimit -t)
    • "data" β€” maximum size of a process’s data segment (ulimit -d)
    • "fsize" β€” maximum size of new files (ulimit -f)
    • "locks" β€” maximum number of file locks (ulimit -x)
    • "memlock" β€” maximum amount of locked memory (ulimit -l)
    • "msgqueue" β€” maximum amount of data in message queues (ulimit -q)
    • "nice" β€” niceness adjustment (nice -n, ulimit -e)
    • "nofile" β€” maximum number of open files (ulimit -n)
    • "nproc" β€” maximum number of processes (ulimit -u)
    • "rss" β€” maximum size of a process’s (ulimit -m)
    • "rtprio" β€” maximum real-time scheduling priority (ulimit -r)
    • "rttime" β€” maximum amount of real-time execution between blocking syscalls
    • "sigpending" β€” maximum number of pending signals (ulimit -i)
    • "stack" β€” maximum stack size (ulimit -s) πŸ“
  • --unsetannotation=annotation β€” unset the image annotation, causing the annotation not to be inherited from the base image. πŸ™ˆ
  • --unsetenv=env β€” unset environment variables from the final image. 🌸
  • --unsetlabel=label β€” unset the image label, causing the label not to be inherited from the base image. πŸ’œ
  • --userns=how β€” sets the configuration for user namespaces when handling RUN instructions. The configured value can be "" (the empty string) or "container" to indicate that a new user namespace is created, it can be "host" to indicate that the user namespace in which podman itself is being run is reused, or it can be the path to a user namespace which is already in use by another process. 🫢
  • --userns-gid-map=mapping β€” directly specifies a GID mapping to be used to set ownership, at the filesystem level, on the working container’s contents. Commands run when handling RUN instructions defaults to being run in their own user namespaces, configured using the UID and GID maps.

Entries in this map take the form of one or more triples of a starting in-container GID, a corresponding starting host-level GID, and the number of consecutive IDs which the map entry represents.

This option overrides the remap-gids setting in the options section of /etc/containers/storage.conf.

If this option is not specified, but a global --userns-gid-map setting is supplied, settings from the global option is used.

If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-gid-map are specified, but --userns-uid-map is specified, the GID map is set to use the same numeric values as the UID map. πŸ’–

  • --userns-gid-map-group=group β€” okay so this tells podman that a GID mapping for setting ownership at the filesystem level on the working container’s contents can be found in /etc/subgid entries that correspond to group. Commands run when handling RUN instructions default to being run in their own user namespaces, configured using the UID and GID maps. If --userns-uid-map-user is specified but --userns-gid-map-group is not, podman assumes that the specified user name is also a suitable group name to use as the default setting for this option.
NOTE: when a rootless user specifies this option, the mappings are relative to the rootless user namespace in the container, not relative to the host like when run rootful. lowkey important πŸ’…
  • --userns-uid-map=mapping β€” directly specifies a UID mapping used to set ownership at the filesystem level on the working container’s contents. Commands run when handling RUN instructions default to being run in their own user namespaces, configured using the UID and GID maps.

Entries in this map are one or more triples of: a starting in-container UID, a corresponding starting host-level UID, and the number of consecutive IDs that the map entry represents.

This option overrides the remap-uids setting in the options section of /etc/containers/storage.conf.

If this option is not specified but a global --userns-uid-map setting is supplied, settings from the global option are used.

If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-uid-map are specified, but --userns-gid-map is specified, the UID map is set to use the same numeric values as the GID map. slay, symmetry ✨

  • --userns-uid-map-user=user β€” specifies that a UID mapping used to set ownership at the filesystem level on the working container’s contents can be found in /etc/subuid entries that correspond to the specified user. Commands run when handling RUN instructions default to being run in their own user namespaces, configured using the UID and GID maps. If --userns-gid-map-group is specified but --userns-uid-map-user is not, podman assumes that the specified group name is also a suitable user name to use as the default setting for this option.
NOTE: when a rootless user specifies this option, the mappings are relative to the rootless user namespace in the container, not relative to the host like when run rootful. same energy as above, bestie 🫢
  • --uts=how β€” sets the configuration for UTS namespaces when handling RUN instructions. The value can be "" (the empty string) or "container" to indicate a new UTS namespace should be created, or "host" to reuse the UTS namespace that podman itself is running in, or it can be the path to a UTS namespace already in use by another process.
  • --volume, -v=[HOST-DIR:CONTAINER-DIR[:OPTIONS]] β€” mounts a host directory into containers when executing RUN instructions during the build. iconic behavior honestly πŸŽ€

The OPTIONS are a comma-separated list and can be one or more of:

  • [rw|ro]
  • [z|Z|O]
  • [U]
  • [[r]shared|[r]slave|[r]private][1]

The CONTAINER-DIR must be an absolute path such as /src/docs. The HOST-DIR must be an absolute path as well. Podman bind-mounts the HOST-DIR to the specified path when processing RUN instructions.

You can specify multiple -v options to mount one or more mounts.

You can add the :ro or :rw suffix to a volume to mount it read-only or read-write mode, respectively. By default, volumes are mounted read-write. See examples. no cap πŸ‘‘

Chowning Volume Mounts πŸ’–

By default, Podman does not change the owner and group of source volume directories mounted. When running using user namespaces, the UID and GID inside the namespace may correspond to another UID and GID on the host.

The :U suffix tells Podman to use the correct host UID and GID based on the UID and GID within the namespace, to recursively change the owner and group of the source volume.

Warning: use with caution since this modifies the host filesystem. literally do not play with this πŸ™ˆ

Labeling Volume Mounts 🏷️

Labeling systems like SELinux require proper labels on volume content mounted into a container. Without a label, the security system might prevent the processes running inside the container from using the content. By default, Podman does not change the labels set by the OS.

To change a label in the container context, add one of these two suffixes :z or :Z to the volume mount. These suffixes tell Podman to relabel file objects on the shared volumes. The z option tells Podman that two containers share the volume content. As a result, Podman labels the content with a shared content label. Shared volume labels allow all containers to read/write content. The Z option tells Podman to label the content with a private unshared label. Only the current container can use a private volume. πŸ’…

Note: do not relabel system files and directories. Relabeling system content might cause other confined services on the host machine to fail. For these types of containers, disabling SELinux separation is recommended. The option --security-opt label=disable disables SELinux separation for the container. For example, if a user wanted to volume mount their entire home directory into the build containers, they need to disable SELinux separation.
$ podman build --security-opt label=disable -v $HOME:/home/user .

Overlay Volume Mounts 🌈

The :O flag tells Podman to mount the directory from the host as temporary storage using the Overlay file system. The RUN command containers are allowed to modify contents within the mountpoint, and those changes are stored in the container storage in a separate directory. In Overlay FS terms, the source directory is the lower, and the container storage directory is the upper. Modifications to the mount point are destroyed when the RUN command finishes executing, similar to a tmpfs mount point.

Any subsequent execution of RUN commands sees the original source directory content; any changes from previous RUN commands no longer exist.

One use case of the overlay mount is sharing the package cache from the host into the container to allow speeding up builds. big brain energy πŸ”₯

Note: - Overlay mounts are not currently supported in rootless mode. - The O flag is not allowed to be specified with the Z or z flags. Content mounted into the container is labeled with the private label. On SELinux systems, labels in the source directory need to be readable by the container label. If not, SELinux container separation must be disabled for the container to work. - Modification of the directory volume mounted into the container with an overlay mount can cause unexpected failures. Do not modify the directory until the container finishes running. fr fr, just don’t 😭

By default bind mounted volumes are private. That means any mounts done inside containers aren’t visible on the host and vice versa. This behavior can be changed by specifying a volume mount propagation property.

When the mount propagation policy is set to shared, any mounts completed inside the container on that volume are visible to both the host and container. When the mount propagation policy is set to slave, one-way mount propagation is enabled and any mounts completed on the host for that volume are visible only inside the container. To control the mount propagation property of a volume, use the :[r]shared, :[r]slave or :[r]private propagation flag. For mount propagation to work, the source mount point (the mount point where the source dir is mounted on) has to have the right propagation properties. For shared volumes, the source mount point has to be shared. And for slave volumes, the source mount has to be either shared or slave. [1]

Use df <source-dir> to determine the source mount and then use findmnt -o TARGET,PROPAGATION <source-mount-dir> to determine propagation properties of the source mount. If the findmnt utility is not available, the source mount point can be determined by looking at the mount entry in /proc/self/mountinfo. Look at optional fields and see if any propagation properties are specified. shared:X means the mount is shared, master:X means the mount is slave, and if nothing is there that means the mount is private. [1]

To change propagation properties of a mount point use the mount command. For example, to bind mount the source directory /foo do:

mount --bind /foo /foo
mount --make-private --make-shared /foo

This converts /foo into a shared mount point. The propagation properties of the source mount can be changed directly. For instance if / is the source mount for /foo, then use:

mount --make-shared /

to convert / into a shared mount.


πŸ§ͺ EXAMPLES πŸ§ͺ

Build named image and manifest list using the specified Containerfile with default farm:

$ podman farm build --local -t name -f /path/to/containerfile .

Build named image and manifest list using the specified farm:

$ podman farm build --farm myfarm -t name .

Build named image and manifest list using the specified farm, removing all images from farm nodes after they are pushed to registry:

$ podman farm build --farm myfarm --cleanup -t name .

Build named images and manifest list for specified platforms using default farm:

$ podman farm build --platforms arm64,amd64 -t name .

πŸ‘€ SEE ALSO πŸ‘€

podman(1), podman-farm(1), buildah(1), containers-certs.d(5), containers-registries.conf(5), crun(1), runc(8), useradd(8), Containerfile(5), containerignore(5)


πŸ“œ HISTORY πŸ“œ

September 2023, originally compiled by Urvashi Mohnani <umohnani@redhat.com>


πŸ“ FOOTNOTES πŸ“

  1. The Podman project is committed to inclusivity, a core value of open source. The master and slave mount propagation terminology used here is problematic and divisive, and needs to be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Podman will follow suit immediately. πŸ’œ

okay bestie, that’s the whole page β€” podman-farm-build(1), September 2023, originally compiled by Urvashi Mohnani. go build something iconic πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from