Product Docs
Open Source
Education
Base images with just enough files to run static binaries!
These images are meant to be used as a base image only and cannot be run directly.
There are two variants: latest, which contains base OS files from Alpine and latest-glibc which contains base OS files from Wolfi.
latest
latest-glibc
Both are largely equivalent and can be used to host completely static binaries, such as those generated by gcc, rust or go with the appropriate arguments, as shown in the examples below. There is no libc implementation in either image, despite the naming convention.
See musl-dynamic and glibc-dynamic for images with the C standard library included.
The image is available on cgr.dev:
cgr.dev
docker pull cgr.dev/chainguard/static:latest
Here’s an example Dockerfile that builds a Rust static binary and puts it into the static image:
FROM cgr.dev/chainguard/rust as build RUN echo 'fn main() { println!("Hello"); }' > hello.rs RUN rustc -C target-feature=+crt-static hello.rs FROM cgr.dev/chainguard/static:latest COPY --from=build /work/hello /hello CMD ["/hello"]
To build and run it:
$ docker build -t rusty-cgr --file examples/Dockerfile.rust . ... $ docker run rusty-cgr Hello
Note the size!
$ docker images rusty-cgr REPOSITORY TAG IMAGE ID CREATED SIZE rusty-cgr latest c3793a4d4270 22 seconds ago 3.33MB
And a C static binary:
# syntax=docker/dockerfile:1.4 FROM cgr.dev/chainguard/gcc-glibc as build COPY <<EOF /hello.c #include <stdio.h> int main() { printf("Hello!"); } EOF RUN cc -static /hello.c -o /hello FROM cgr.dev/chainguard/static:latest COPY --from=build /hello /hello CMD ["/hello"]
$ docker build -t c-cgr -f examples/Dockerfile.c . ... $ docker run c-cgr Hello!
It’s even smaller:
$ docker images c-cgr REPOSITORY TAG IMAGE ID CREATED SIZE c-cgr latest a6671209830b 9 seconds ago 2.78MB
For Go programs, we recommend using ko and setting the defaultBaseImage to cgr.dev/chainguard/static.
defaultBaseImage
cgr.dev/chainguard/static
The image has a single user nonroot with uid 65532, belonging to gid 65532.
nonroot
65532