---
title: "lean build"
description: "API reference for the command `lean build` in command line console."
canonical: https://www.quantconnect.com/docs/v2/lean-cli/api-reference/lean-build
markdown: https://www.quantconnect.com/docs/v2/lean-cli/api-reference/lean-build.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/05%20Lean%20CLI/99%20API%20Reference/02%20lean%20build
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# lean build

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Lean CLI](https://www.quantconnect.com/docs/v2/lean-cli.md) > [API Reference](https://www.quantconnect.com/docs/v2/lean-cli/api-reference.md) > lean build

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Build Docker images of your own version of LEAN.

```
$ lean build [OPTIONS] [ROOT]
```

To use the CLI, you must be a member in an [organization](https://www.quantconnect.com/docs/v2/cloud-platform/organizations/tier-features.md) on a paid tier.

## Description

Builds local Docker images of a local version of LEAN and sets them up for local usage with the CLI. After running this command, all commands that run the LEAN engine or the research environment use your custom images. This command performs the following actions:

1. The `lean-cli/foundation:latest` image is built from `Lean / DockerfileLeanFoundation` (if you're using an AMD64-based system) or `Lean / DockerfileLeanFoundationARM` (if you're using an ARM64-based system).
2. LEAN is compiled in a Docker container using the `lean-cli/foundation:latest` image.
3. The `lean-cli/engine:latest` image is built from `Lean / Dockerfile` using `lean-cli/foundation:latest` as the base image.
4. The `lean-cli/research:latest` image is built from `Lean / DockerfileJupyter` using `lean-cli/engine:latest` as the base image.
5. The default engine image is set to `lean-cli/engine:latest`.
6. The default research image is set to `lean-cli/research:latest`.

When the foundation Dockerfile is the same as the one used for the official foundation image, step 1 is skipped and `quantconnect/lean:foundation` is used instead of `lean-cli/foundation:latest`.

## Arguments

The `lean build` command expects the following arguments:

| Argument | Description |
| --- | --- |
| `<lean>` | The path to the directory containing the [LEAN](https://github.com/QuantConnect/Lean) repository. Defaults to the current working directory. |

## Options

The `lean build` command supports the following options:

| Option | Description |
| --- | --- |
| `--tag <string>` | The tag to apply to custom images (defaults to latest) |
| `--verbose` | Enable debug logging |
| `--help` | Display the help text of the `lean build` command and exit |
