MCPcopy Index your code
hub / github.com/docker/docker-py / build

Method build

docker/models/images.py:220–315  ·  view source on GitHub ↗

Build an image and return it. Similar to the ``docker build`` command. Either ``path`` or ``fileobj`` must be set. If you already have a tar file for the Docker build context (including a Dockerfile), pass a readable file-like object to ``fileobj`` and also

(self, **kwargs)

Source from the content-addressed store, hash-verified

218 model = Image
219
220 def build(self, **kwargs):
221 """
222 Build an image and return it. Similar to the ``docker build``
223 command. Either ``path`` or ``fileobj`` must be set.
224
225 If you already have a tar file for the Docker build context (including
226 a Dockerfile), pass a readable file-like object to ``fileobj``
227 and also pass ``custom_context=True``. If the stream is also
228 compressed, set ``encoding`` to the correct value (e.g ``gzip``).
229
230 If you want to get the raw output of the build, use the
231 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
232 low-level API.
233
234 Args:
235 path (str): Path to the directory containing the Dockerfile
236 fileobj: A file object to use as the Dockerfile. (Or a file-like
237 object)
238 tag (str): A tag to add to the final image
239 quiet (bool): Whether to return the status
240 nocache (bool): Don't use the cache when set to ``True``
241 rm (bool): Remove intermediate containers. The ``docker build``
242 command now defaults to ``--rm=true``, but we have kept the old
243 default of `False` to preserve backward compatibility
244 timeout (int): HTTP timeout
245 custom_context (bool): Optional if using ``fileobj``
246 encoding (str): The encoding for a stream. Set to ``gzip`` for
247 compressing
248 pull (bool): Downloads any updates to the FROM image in Dockerfiles
249 forcerm (bool): Always remove intermediate containers, even after
250 unsuccessful builds
251 dockerfile (str): path within the build context to the Dockerfile
252 buildargs (dict): A dictionary of build arguments
253 container_limits (dict): A dictionary of limits applied to each
254 container created by the build process. Valid keys:
255
256 - memory (int): set memory limit for build
257 - memswap (int): Total memory (memory + swap), -1 to disable
258 swap
259 - cpushares (int): CPU shares (relative weight)
260 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
261 ``"0-3"``, ``"0,1"``
262 shmsize (int): Size of `/dev/shm` in bytes. The size must be
263 greater than 0. If omitted the system uses 64MB
264 labels (dict): A dictionary of labels to set on the image
265 cache_from (list): A list of images used for build cache
266 resolution
267 target (str): Name of the build-stage to build in a multi-stage
268 Dockerfile
269 network_mode (str): networking mode for the run commands during
270 build
271 squash (bool): Squash the resulting images layers into a
272 single layer.
273 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
274 containers, as a mapping of hostname to IP address.
275 platform (str): Platform in the format ``os[/arch[/variant]]``.
276 isolation (str): Isolation technology used during build.
277 Default: `None`.

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
json_streamFunction · 0.90
BuildErrorClass · 0.85
searchMethod · 0.45

Tested by

no test coverage detected