docker buildx build

Estimated reading time: 3 minutes

Description

Start a build

This command is experimental on the Docker client.

It should not be used in production environments.

To enable experimental features in the Docker CLI, edit the config.json and set experimental to enabled. You can go here for more information.

Usage

docker buildx build [OPTIONS] PATH | URL | -

Options

Name, shorthand Default Description
--add-host Add a custom host-to-IP mapping (host:ip)
--build-arg Set build-time variables
--cache-from External cache sources (eg. user/app:cache, type=local,src=path/to/dir)
--cache-to Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)
--cgroup-parent Optional parent cgroup for the container
--compress Compress the build context using gzip
--cpu-period Limit the CPU CFS (Completely Fair Scheduler) period
--cpu-quota Limit the CPU CFS (Completely Fair Scheduler) quota
--cpu-shares , -c CPU shares (relative weight)
--cpuset-cpus CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems MEMs in which to allow execution (0-3, 0,1)
--file , -f Name of the Dockerfile (Default is ‘PATH/Dockerfile’)
--force-rm Always remove intermediate containers
--iidfile Write the image ID to the file
--isolation Container isolation technology
--label Set metadata for an image
--load Shorthand for --output=type=docker
--memory , -m Memory limit
--memory-swap Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap
--network Set the networking mode for the RUN instructions during build
--no-cache Do not use cache when building the image
--output , -o Output destination (format: type=local,dest=path)
--platform Set target platform for build
--progress auto Set type of progress output (auto, plain, tty). Use plain to show container output
--pull Always attempt to pull a newer version of the image
--push Shorthand for --output=type=registry
--quiet , -q Suppress the build output and print image ID on success
--rm true Remove intermediate containers after a successful build
--secret Secret file to expose to the build: id=mysecret,src=/local/secret
--security-opt Security options
--shm-size Size of /dev/shm
--squash Squash newly built layers into a single new layer
--ssh SSH agent socket or keys to expose to the build (format: default|[=|[,]])
--tag , -t Name and optionally a tag in the ‘name:tag’ format
--target Set the target build stage to build.
--ulimit Ulimit options

Parent command

Command Description
docker buildx Build with BuildKit
Command Description
docker buildx bake Build from a file
docker buildx build Start a build
docker buildx create Create a new builder instance
docker buildx imagetools Commands to work on images in registry
docker buildx inspect Inspect current builder instance
docker buildx ls List builder instances
docker buildx rm Remove a builder instance
docker buildx stop Stop builder instance
docker buildx use Set the current builder instance
docker buildx version Show buildx version information