Build an image and return it. Similar to the dockerbuild
command. Either path or fileobj must be set.

If you have a tar file for the Docker build context (including a
Dockerfile) already, pass a readable file-like object to fileobj
and also pass custom_context=True. If the stream is compressed
also, set encoding to the correct value (e.g gzip).

If you want to get the raw output of the build, use the
build() method in the
low-level API.

Args:

path (str): Path to the directory containing the Dockerfile
fileobj: A file object to use as the Dockerfile. (Or a file-like

object)

tag (str): A tag to add to the final image
quiet (bool): Whether to return the status
nocache (bool): Don’t use the cache when set to True
rm (bool): Remove intermediate containers. The dockerbuild

command now defaults to --rm=true, but we have kept the old
default of False to preserve backward compatibility

timeout (int): HTTP timeout
custom_context (bool): Optional if using fileobj
encoding (str): The encoding for a stream. Set to gzip for

compressing

pull (bool): Downloads any updates to the FROM image in Dockerfiles
forcerm (bool): Always remove intermediate containers, even after

unsuccessful builds

dockerfile (str): path within the build context to the Dockerfile
buildargs (dict): A dictionary of build arguments
container_limits (dict): A dictionary of limits applied to each

container created by the build process. Valid keys:

memory (int): set memory limit for build

memswap (int): Total memory (memory + swap), -1 to disable

swap

cpushares (int): CPU shares (relative weight)

cpusetcpus (str): CPUs in which to allow execution, e.g.,

"0-3", "0,1"

shmsize (int): Size of /dev/shm in bytes. The size must be

greater than 0. If omitted the system uses 64MB

labels (dict): A dictionary of labels to set on the image
cache_from (list): A list of images used for build cache