docker image build
Estimated reading time: 3 minutesEdge only: This is the CLI reference for Docker CE Edge versions. Some of these options may not be available to Docker CE stable or Docker EE. You can view the stable version of this CLI reference or learn about Docker CE Edge.
Description
Build an image from a Dockerfile
Usage
docker image 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 |
Images to consider as cache sources | |
--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) | |
--disable-content-trust |
true |
Skip image verification |
--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 | |
--memory , -m |
Memory limit | |
--memory-swap |
Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap | |
--network |
API 1.25+ Set the networking mode for the RUN instructions during build |
|
--no-cache |
Do not use cache when building the image | |
--pull |
Always attempt to pull a newer version of the image | |
--quiet , -q |
Suppress the build output and print image ID on success | |
--rm |
true |
Remove intermediate containers after a successful build |
--security-opt |
Security options | |
--shm-size |
Size of /dev/shm | |
--squash |
API 1.25+ experimental Squash newly built layers into a single new layer |
|
--stream |
API 1.31+ experimental Stream attaches to server to negotiate build context |
|
--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 image | Manage images |
Related commands
Command | Description |
docker image build | Build an image from a Dockerfile |
docker image history | Show the history of an image |
docker image import | Import the contents from a tarball to create a filesystem image |
docker image inspect | Display detailed information on one or more images |
docker image load | Load an image from a tar archive or STDIN |
docker image ls | List images |
docker image prune | Remove unused images |
docker image pull | Pull an image or a repository from a registry |
docker image push | Push an image or a repository to a registry |
docker image rm | Remove one or more images |
docker image save | Save one or more images to a tar archive (streamed to STDOUT by default) |
docker image tag | Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE |