/
DirectorySecurity AdvisoriesPricing
Sign in
Directory
rust logo

rust

Last changed

Try a starter image for free
docker pull cgr.dev/chainguard/rust

Need access to a specific tag? Contact us.

Create your free account

Integrate Chainguard into your developer workflows, manage your image versions to stay free of CVEs, and view critical SBOM and provenance details.

Sign up
Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for rust

Minimal Wolfi-based Rust image for building Rust applications.

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/rust:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

  • Documentation
  • Provenance Information

This image contains the tools needed to build Rust code. This includes:

  • rustc
  • cargo
  • cargo-auditable wrapper
  • rustdoc
  • rustlldb
  • rust-audit-info
  • And more!

This image also includes a shell for compatibility with most cargo package installations. This image is not intended to be used as a runtime image, only as a build tool.

Rust Version

This will automatically pull the image to your local system and execute the command rustc --version:

docker run --rm cgr.dev/chainguard/rust --version

You should get output similar to this:

rustc 1.67.1 (d5a82bbd2 2023-02-07) (built from a source tarball)

Cargo Auditable

By default /usr/local/bin/cargo contains a wrapper to always call cargo auditable which generates and embeds build time crate information in the compiled binaries. This enables inspecting compiled rust binaries with rust-audit-info which is also included in this image. Many security scanners also know how to parse this information for the purpose of detecting security vulnerabilities. For more information see Cargo Auditable project.

Building without audit information is possible by invoking /usr/bin/cargo directly, however doing that will evade scanner support in the resulting binaries.

Application Setup for End Users

For runtime, you can use a multi-stage Dockerfile or similar technique to run your compiled binaries on an even more slimmed down image. The exact image will depend on your application, but static or glibc-dynamic should work.

This sample Dockerfile shows how to get a basic build up and running on glibc-dynamic. There's one build argument, PACKAGE, that needs to be replaced with the name of your rust package.

ARG PACKAGE=myapp

FROM cgr.dev/chainguard/rust as build
WORKDIR /app
COPY . .
RUN cargo build --release

FROM cgr.dev/chainguard/glibc-dynamic
COPY --from=build --chown=nonroot:nonroot /app/target/release/${PACKAGE} /usr/local/bin/${PACKAGE}
CMD ["/usr/local/bin/${PACKAGE}"]
$ docker build -t foo --build-arg PACKAGE=shop .
[+] Building 74.4s (12/12) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                                         0.0s
 => => transferring dockerfile: 291B                                                                                                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                                                              0.0s
 => [internal] load metadata for cgr.dev/chainguard/glibc-dynamic:latest                                                                                                                                                                                0.0s
 => [internal] load metadata for cgr.dev/chainguard/rust:latest                                                                                                                                                                              0.0s
 => [internal] load build context                                                                                                                                                                                                            0.0s
 => => transferring context: 6.21kB                                                                                                                                                                                                          0.0s
 => [stage-1 1/2] FROM cgr.dev/chainguard/glibc-dynamic                                                                                                                                                                                                 0.0s
 => [build 1/4] FROM cgr.dev/chainguard/rust                                                                                                                                                                                                 0.0s
 => CACHED [build 2/4] WORKDIR /app                                                                                                                                                                                                          0.0s
 => [build 3/4] COPY . .                                                                                                                                                                                                                     0.0s
 => [build 4/4] RUN cargo build --release                                                                                                                                                                                                   73.9s
 => [stage-1 2/2] COPY --from=build --chown=nonroot:nonroot /app/target/release/shop /usr/local/bin/shop                                                                                                                                     0.1s
 => exporting to image                                                                                                                                                                                                                       0.1s
 => => exporting layers                                                                                                                                                                                                                      0.0s
 => => writing image sha256:cf84a39643bc196611fa01819a91d31e34da74128499db74b75e1da3faa77bae                                                                                                                                                 0.0s
 => => naming to docker.io/library/foo                                                                                                                                                                                                       0.0s
dlorenc@DANIELs-MacBook-Air rust-web-app % docker run foo /usr/local/bin/shop
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"shop::api","@m":"starting up"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"🔧 Configured for release."}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"address: \u001b[1;49;39m127.0.0.1\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"port: \u001b[1;49;39m8000\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"workers: \u001b[1;49;39m8\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"ident: \u001b[1;49;39mRocket\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"limits: \u001b[1;49;39mbytes = 8KiB, data-form = 2MiB, file = 1MiB, form = 32KiB, json = 1MiB, msgpack = 1MiB, string = 8KiB\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"temp dir: \u001b[1;49;39m/tmp\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"http/2: \u001b[1;49;39mtrue\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"keep-alive: \u001b[1;49;39m5\u001b[0m\u001b[1;49;39ms\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"tls: \u001b[1;49;39mdisabled\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"shutdown: \u001b[1;49;39mctrlc = true, force = true, signals = [SIGTERM], grace = 2s, mercy = 3s\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"log level: \u001b[1;49;39mcritical\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::config::config","@m":"cli colors: \u001b[1;49;39mtrue\u001b[0m"}
{"@t":"2022-12-30T15:27:10Z","@l":"INFO","module_path":"rocket::rocket","@m":"📬 \u001b[35mRoutes\u001b[0m:"}

If you're interested in enterprise support, SLAs, and access to older tags, get in touch.

What are Chainguard Containers?

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.

Need additional packages?

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.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Libraries — contact us for access.

Trademarks

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.

Licenses

Chainguard container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • Apache-2.0

  • BSD-2-Clause

  • BSD-3-Clause

  • CC-BY-4.0

  • GCC-exception-3.1

  • GPL-2.0

  • GPL-2.0-only

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Category
featured
starter
base

Safe Source for Open Sourceâ„¢
Contact us
© 2025 Chainguard. All Rights Reserved.
Private PolicyTerms of Use

Product

Chainguard ContainersChainguard LibrariesChainguard VMsIntegrationsPricing