docker-build - Man Page

Build an image from a Dockerfile

Examples (TL;DR)


docker build [Options] PATH | URL | -


Build an image from a Dockerfile



Add a custom host-to-IP mapping (host:ip)


Set build-time variables


Images to consider as cache sources


Optional parent cgroup for the container


Compress the build context using gzip


Show console output (with buildkit only) (true, false, auto)


Limit the CPU CFS (Completely Fair Scheduler) period


Limit the CPU CFS (Completely Fair Scheduler) quota

-c, --cpu-shares=0

CPU shares (relative weight)


CPUs in which to allow execution (0-3, 0,1)


MEMs in which to allow execution (0-3, 0,1)


Skip image verification

-f, --file=""

Name of the Dockerfile (Default is 'PATH/Dockerfile')


Always remove intermediate containers

-h, --help[=false]

help for build


Write the image ID to the file


Container isolation technology


Set metadata for an image

-m, --memory=0

Memory limit


Swap limit equal to memory plus swap: '-1' to enable unlimited swap


Set the networking mode for the RUN instructions during build


Do not use cache when building the image


Set platform if server is multi-platform capable


Always attempt to pull a newer version of the image

-q, --quiet[=false]

Suppress the build output and print image ID on success


Remove intermediate containers after a successful build


Security options


Size of /dev/shm


Squash newly built layers into a single new layer


Stream attaches to server to negotiate build context

-t, --tag=

Name and optionally a tag in the 'name:tag' format


Set the target build stage to build.


Ulimit options

See Also


Referenced By


Aug 2018 Docker Community