---
title: Optimize for building in the cloud
linkTitle: Optimization
weight: 40
description: Building remotely is different from building locally. Here's how to optimize for remote builders.
keywords: build, cloud build, optimize, remote, local, cloud
aliases:
- /build/cloud/optimization/
---
Docker Build Cloud runs your builds remotely, and not on the machine where you
invoke the build. This means that file transfers between the client and builder
happen over the network.
Transferring files over the network has a higher latency and lower bandwidth
than local transfers. Docker Build Cloud has several features to mitigate this:
- It uses attached storage volumes for build cache, which makes reading and
writing cache very fast.
- Loading build results back to the client only pulls the layers that were
changed compared to previous builds.
Despite these optimizations, building remotely can still yield slow context
transfers and image loads, for large projects or if the network connection is
slow. Here are some ways that you can optimize your builds to make the transfer
more efficient:
- [Dockerignore files](#dockerignore-files)
- [Slim base images](#slim-base-images)
- [Multi-stage builds](#multi-stage-builds)
- [Fetch remote files in build](#fetch-remote-files-in-build)
- [Multi-threaded tools](#multi-threaded-tools)
For more information on how to optimize your builds, see
[Building best practices](/manuals/build/building/best-practices.md).
### Dockerignore files
Using a [`.dockerignore` file](/manuals/build/concepts/context.md#dockerignore-files),
you can be explicit about which local files you don’t want to include in the
build context. Files caught by the glob patterns you specify in your
ignore-file aren't transferred to the remote builder.
Some examples of things you might want to add to your `.dockerignore` file are:
- `.git` — skip sending the version control history in the build context. Note
that this means you won’t be able to run Git commands in your build steps,
such as `git rev-parse`.
- Directories containing build artifacts, such as binaries. Build artifacts
created locally during development.