packaged by Chainguard
Catalog Starter gives your team 5 production-grade container images, free forever, with no contract or sales call. Sign up with your work email.
Try Starter for freeLean 4 programming language and proof assistant, with a variant that includes the Mathlib math library, ready to use with no download.
Chainguard Containers are regularly-updated, secure-by-default container images.
For those with access, this container image is available on cgr.dev:
Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.
Lean is a programming language and proof assistant: you write definitions and theorems, and Lean checks that every proof is correct. The lean image comes in two variants, and each has a -dev version:
| Tag | Use it when | Size |
|---|---|---|
| You write Lean programs or proofs that need only Lean's built-in libraries. | about 5 GB |
| You want Mathlib, the community library of formalized mathematics, or CSLib, its computer science counterpart. Both come compiled, so | about 12 GB |
| You want to work inside the container, or build your own image on top of it. The | slightly larger |
Each tag also comes with the Lean version in its name, such as <version> or <version>-mathlib. The -mathlib tags follow the newest Lean release that Mathlib and CSLib support, so for a short time after a Lean release they can have an older Lean than the other tags. Use the tags without -dev in CI and production, where you need fewer packages.
The image works like the community leanprovercommunity/lean4 image: its entrypoint is a bash login shell, and it runs as the user lean (UID 1000) in /home/lean.
The first pull downloads about 5 GB, or about 12 GB for a -mathlib tag, so allow for the time and disk space.
A file that does import Mathlib loads about 6.5 GB of library files. Lean still runs with less memory than that, but it is then slower, because it reads the files from disk again on each run. To keep the files in memory between runs, give Docker Desktop or your CI runner more memory than that, or import only the parts of Mathlib that a file uses, such as import Mathlib.Tactic.Ring.
Start a shell in the container, with Lean and Lake on the PATH:
To check a file instead, create one that proves an identity with Mathlib and prints a value:
Mount the current directory into the container, and pass the command to the shell with -c:
Lean prints the value of the #eval line, and no errors, because the proof is correct:
If you change the theorem to a false statement, Lean prints an error that names the step that failed. A proof that uses sorry passes with a warning; add -DwarningAsError=true to make that an error.
Lake is Lean's build tool, and it comes with Lean. A Lake project keeps its settings in a lakefile.toml file, and lake build checks and compiles all of the project's files.
Create a library project in the current directory. The container runs as UID 1000. On Linux, if your user has a different UID, the container cannot write to the mounted directory, so add --user "$(id -u):$(id -g)". The files then belong to you:
Replace its module with one that uses Mathlib and CSLib:
Build it, treating warnings as errors:
Do not add require mathlib or require cslib to the lakefile. Without them, Lake uses the copies that come with the image. With them, Lake downloads and builds its own copies, which takes hours and needs network access.
Lean users often install elan, which installs the Lean version that each project names in its lean-toolchain file. No tag includes elan, and the images do not read lean-toolchain files, because elan downloads Lean from upstream, not from Chainguard. To stay on Chainguard's Lean, choose the image tag that matches the Lean version your project uses.
If you need elan, install the Chainguard package in a -dev image, then register the image's Lean under the name that elan uses:
lake new writes that name, leanprover/lean4:v<version>, to a new project's lean-toolchain file, so the project builds with the image's Lean and elan downloads nothing. A project that names any other Lean version makes elan download it from upstream, and that version cannot use the libraries that come with a -mathlib image.
/usr, and the image's version tags name that Lean release. Every library in the image is compiled with that release./usr/lib/lean, where lean and lake always look for them, and their sources install under /usr/src/lean, so an editor can jump to a definition. The image does not set LEAN_PATH.#eval and lean --run. A native program that you build with lake build can only call Lean's built-in libraries (Init, Std, and Lean), not Mathlib or CSLib.runAsNonRoot can check it.Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.
All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.
The main features of Chainguard Containers include:
For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.
In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.
Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.
To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.
To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.
Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Libraries — contact us for access.
This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.
Chainguard's container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:
For a complete list of licenses, please refer to this Image's SBOM.
Software license agreementChainguard Containers are SLSA Level 3 compliant with detailed metadata and documentation about how it was built. We generate build provenance and a Software Bill of Materials (SBOM) for each release, with complete visibility into the software supply chain.
SLSA compliance at ChainguardThis image helps reduce time and effort in establishing PCI DSS 4.0 compliance with low-to-no CVEs.
PCI DSS at Chainguard