Docker Engine API
  1. Image
Docker Engine API
  • System
    • Ping
      GET
    • Check auth configuration
      POST
    • Monitor events
      GET
    • Get system information
      GET
    • Get data usage information
      GET
    • Get version
      GET
  • Image
    • Build an image
      POST
    • Delete builder cache
      POST
    • Create a new image from a container
      POST
    • Create an image
      POST
    • Export several images
      GET
    • List Images
      GET
    • Import images
      POST
    • Delete unused images
      POST
    • Search images
      GET
    • Remove an image
      DELETE
    • Export an image
      GET
    • Get the history of an image
      GET
    • Inspect an image
      GET
    • Push an image
      POST
    • Tag an image
      POST
  • Config
    • List configs
      GET
    • Create a config
      POST
    • Delete a config
      DELETE
    • Inspect a config
      GET
    • Update a Config
      POST
  • Container
    • Create a container
    • List containers
    • Delete stopped containers
    • Remove a container
    • Get an archive of a filesystem resource in a container
    • Get information about files in a container
    • Extract an archive of files or folders to a directory in a container
    • Attach to a container
    • Attach to a container via a websocket
    • Get changes on a container’s filesystem
    • Export a container
    • Inspect a container
    • Kill a container
    • Get container logs
    • Pause a container
    • Rename a container
    • Resize a container TTY
    • Restart a container
    • Start a container
    • Get container stats based on resource usage
    • Stop a container
    • List processes running inside a container
    • Unpause a container
    • Update a container
    • Wait for a container
  • Exec
    • Create an exec instance
    • Inspect an exec instance
    • Resize an exec instance
    • Start an exec instance
  • Distribution
    • Get image information from the registry
  • Network
    • List networks
    • Create a network
    • Delete unused networks
    • Remove a network
    • Inspect a network
    • Connect a container to a network
    • Disconnect a container from a network
  • Node
    • List nodes
    • Delete a node
    • Inspect a node
    • Update a node
  • Plugin
    • List plugins
    • Create a plugin
    • Get plugin privileges
    • Install a plugin
    • Remove a plugin
    • Disable a plugin
    • Enable a plugin
    • Inspect a plugin
    • Push a plugin
    • Configure a plugin
    • Upgrade a plugin
  • Secret
    • List secrets
    • Create a secret
    • Delete a secret
    • Inspect a secret
    • Update a Secret
  • Service
    • List services
    • Create a service
    • Delete a service
    • Inspect a service
    • Get service logs
    • Update a service
  • Session (experimental)
    • Initialize interactive session
  • Swarm
    • Inspect swarm
    • Initialize a new swarm
    • Join an existing swarm
    • Leave a swarm
    • Unlock a locked manager
    • Get the unlock key
    • Update a swarm
  • Task
    • List tasks
    • Inspect a task
  • Volume
    • List volumes
    • Create a volume
    • Delete unused volumes
    • Remove a volume
    • Inspect a volume
  • Get task logs
    GET
  1. Image

Build an image

/v1.33
/v1.33
/v1.33
/v1.33
POST
/build
Image
Build an image from a tar archive with a Dockerfile in it.
The Dockerfile specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the dockerfile parameter. See the Dockerfile reference for more information.
The Docker daemon performs a preliminary validation of the Dockerfile before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.
The build is canceled if the client drops the connection by quitting or being killed.
Request Request Example
Shell
JavaScript
Java
Swift
Response Response Example
200 - Example 1
{}

Request

Query Params
dockerfile
string 
optional
Path within the build context to the Dockerfile. This is ignored if remote is specified and points to an external Dockerfile.
t
string 
optional
A name and optional tag to apply to the image in the name:tag format. If you omit the tag the default latest value is assumed. You can provide several t parameters.
extrahosts
string 
optional
Extra hosts to add to /etc/hosts
remote
string 
optional
A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called Dockerfile and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the dockerfile parameter is also specified, there must be a file with the corresponding path inside the tarball.
q
string 
optional
Suppress verbose build output.
nocache
string 
optional
Do not use the cache when building the image.
cachefrom
string 
optional
JSON array of images used for build cache resolution.
pull
string 
optional
Attempt to pull the image even if an older image exists locally.
rm
string 
optional
Remove intermediate containers after a successful build.
forcerm
string 
optional
Always remove intermediate containers, even upon failure.
memory
integer 
optional
Set memory limit for build.
memswap
integer 
optional
Total memory (memory + swap). Set as -1 to disable swap.
cpushares
integer 
optional
CPU shares (relative weight).
cpusetcpus
string 
optional
CPUs in which to allow execution (e.g., 0-3, 0,1).
cpuperiod
integer 
optional
The length of a CPU period in microseconds.
cpuquota
integer 
optional
Microseconds of CPU time that the container can get in a CPU period.
buildargs
integer 
optional
JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the Dockerfile RUN instruction, or for variable expansion in other Dockerfile instructions. This is not meant for passing secret values. Read more about the buildargs instruction.
shmsize
integer 
optional
Size of /dev/shm in bytes. The size must be greater than 0. If omitted the system uses 64MB.
squash
string 
optional
Squash the resulting images layers into a single layer. (Experimental release only.)
labels
string 
optional
Arbitrary key/value labels to set on the image, as a JSON map of string pairs.
networkmode
string 
optional
Sets the networking mode for the run commands during build. Supported standard values are: bridge, host, none, and container:<name|id>. Any other value is taken as a custom network's name to which this container should connect to.
Header Params
Content-type
string 
optional
X-Registry-Config
string 
optional
This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to.
The key is a registry URL, and the value is an auth configuration object, as described in the authentication section. For example:
{
  "docker.example.com": {
    "username": "janedoe",
    "password": "hunter2"
  },
  "https://index.docker.io/v1/": {
    "username": "mobydock",
    "password": "conta1n3rize14"
  }
}
Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a https:// prefix and a /v1/ suffix even though Docker will prefer to use the v2 registry API.
Body Params application/octet-stream
Not configured

Responses

🟢200no error
application/json
Body
object {0}
🟠400Bad parameter
🔴500server error
Modified at 2022-09-10 17:56:06
Previous
Get version
Next
Delete builder cache
Built with