All Projects β†’ GoogleContainerTools β†’ Distroless

GoogleContainerTools / Distroless

Licence: apache-2.0
πŸ₯‘ Language focused docker images, minus the operating system.

Programming Languages

Starlark
911 projects
go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Distroless

Daml
The Daml smart contract language
Stars: ✭ 548 (-95.23%)
Mutual labels:  bazel
Rules go
Go rules for Bazel
Stars: ✭ 852 (-92.58%)
Mutual labels:  bazel
Rules python external
Bazel rules to resolve and fetch artifacts transitively from the Python Package Index (PyPI)
Stars: ✭ 60 (-99.48%)
Mutual labels:  bazel
Startup Os
Working examples of Google's Open Source stack and deployment to the cloud.
Stars: ✭ 564 (-95.09%)
Mutual labels:  bazel
Gazel
DEPRECATED: use gazelle
Stars: ✭ 22 (-99.81%)
Mutual labels:  bazel
Platforms
Constraint values for specifying platforms and toolchains
Stars: ✭ 34 (-99.7%)
Mutual labels:  bazel
Intellij
IntelliJ plugin for Bazel projects
Stars: ✭ 500 (-95.65%)
Mutual labels:  bazel
Cuda Design Patterns
Some CUDA design patterns and a bit of template magic for CUDA
Stars: ✭ 78 (-99.32%)
Mutual labels:  bazel
Rules terraform
Bazel rules for using Hashicorp's Terraform in your Bazel builds.
Stars: ✭ 26 (-99.77%)
Mutual labels:  bazel
Proposals
Index of all Bazel proposals and design documents
Stars: ✭ 50 (-99.56%)
Mutual labels:  bazel
Awesome Bazel
A curated list of Bazel rules, tooling and resources.
Stars: ✭ 640 (-94.43%)
Mutual labels:  bazel
Colossus
Colossus β€”Β An example microservice architecture for Kubernetes using Bazel, Go, Java, Docker, Kubernetes, Minikube, Gazelle, gRPC, Prometheus, Grafana, and more
Stars: ✭ 917 (-92.01%)
Mutual labels:  bazel
Bazel Mypy Integration
πŸπŸŒΏπŸ’š Integrate MyPy type-checking into your Python Bazel builds
Stars: ✭ 40 (-99.65%)
Mutual labels:  bazel
Zhihudailypurify
Purified version of Zhihu Daily - ζ›΄ηΊ―ε‡€ηš„ηŸ₯乎ζ—₯ζŠ₯
Stars: ✭ 4,998 (-56.48%)
Mutual labels:  bazel
Bazel and compilecommands
Add compile_commands.json to your C++ Bazel Project
Stars: ✭ 62 (-99.46%)
Mutual labels:  bazel
Buildtools
A bazel BUILD file formatter and editor
Stars: ✭ 538 (-95.32%)
Mutual labels:  bazel
Rules codeowners
Bazel rules for generating CODEOWNERS from a workspace.
Stars: ✭ 31 (-99.73%)
Mutual labels:  bazel
Rules nixpkgs
Rules for importing Nixpkgs packages into Bazel.
Stars: ✭ 88 (-99.23%)
Mutual labels:  bazel
Bazel Linting System
πŸŒΏπŸ’š Experimental system for registering, configuring, and invoking source-code linters in Bazel.
Stars: ✭ 63 (-99.45%)
Mutual labels:  bazel
Rules grafana
Bazel rules for building Grafana dashboards
Stars: ✭ 46 (-99.6%)
Mutual labels:  bazel

"Distroless" Docker Images

CI Build Status

"Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.

For more information, see this talk (video).

Why should I use distroless images?

Restricting what's in your runtime container to precisely what's necessary for your app is a best practice employed by Google and other tech giants that have used containers in production for many years. It improves the signal to noise of scanners (e.g. CVE) and reduces the burden of establishing provenance to just what you need.

Distroless images are very small. The smallest distroless image, gcr.io/distroless/static-debian11, is around 2 MiB. That's about 50% of the size of alpine (~5 MiB), and less than 2% of the size of debian (124 MiB).

How do I use distroless images?

These images are built using bazel, but they can also be used through other Docker image build tooling.

How do I verify distroless images?

All distroless images are signed by cosign. We recommend verifying any distroless image you use before building your image.

Once you've installed cosign, you can use the distroless public key to verify any distroless image with:

cat cosign.pub
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZzVzkb8A+DbgDpaJId/bOmV8n7Q
OqxYbK0Iro6GzSmOzxkn+N2AKawLyXi84WSwJQBK//psATakCgAQKkNTAA==
-----END PUBLIC KEY-----


cosign verify --key cosign.pub $IMAGE_NAME

Entrypoints

Note that distroless images by default do not contain a shell. That means the Dockerfile ENTRYPOINT command, when defined, must be specified in vector form, to avoid the container runtime prefixing with a shell.

This works:

ENTRYPOINT ["myapp"]

But this does not work:

ENTRYPOINT "myapp"

For the same reasons, if the entrypoint is left to the default empty vector, the CMD command should be specified in vector form (see examples below).

Docker

Docker multi-stage builds make using distroless images easy. Follow these steps to get started:

Examples with Docker

Here's a quick example for go:

# Start by building the application.
FROM golang:1.17-bullseye as build

WORKDIR /go/src/app
ADD . /go/src/app

RUN go get -d -v ./...

RUN go build -o /go/bin/app

# Now copy it into our base image.
FROM gcr.io/distroless/base-debian11
COPY --from=build /go/bin/app /
CMD ["/app"]

You can find other examples here:

To run any example, go to the directory for the language and run

docker build -t myapp .
docker run -t myapp

To run the Node.js Express app node-express and expose the container's ports:

npm install # Install express and its transitive dependencies
docker build -t myexpressapp . # Normal build command
docker run -p 3000:3000 -t myexpressapp

This should expose the Express application to your localhost:3000

Bazel

For full documentation on how to use bazel to generate Docker images, see the bazelbuild/rules_docker repository.

For documentation and examples on how to use the bazel package manager rules, see ./package_manager

Examples can be found in this repository in the examples directory.

Examples with Bazel

We have some examples on how to run some common application stacks in the /examples directory. See here for:

See here for examples on how to complete some common tasks in your image:

See here for more information on how these images are built and released.

Jib

For full documentation on how to use Jib to generate Docker images from Maven and Gradle, see the GoogleContainerTools/jib repository.

Base Operating System

Distroless images are based on Debian 11 (bullseye). Images are explicitly tagged with Debian version suffixes (e.g. -debian10 or -debian11). Specifying an image without the distribution will currently select -debian11 images, but that will change in the future to a newer version of Debian. It can be useful to reference the distribution explicitly, to prevent breaking builds when the next Debian version is released.

Operating System Updates for Security Fixes and CVEs

Distroless tracks the upstream Debian releases, using Github actions to automatically generate a pull request when there are updates.

Debug Images

Distroless images are minimal and lack shell access. The :debug image set for each language provides a busybox shell to enter.

For example:

cd examples/python3/

edit the Dockerfile to change the final image to :debug:

FROM gcr.io/distroless/python3-debian11:debug
COPY . /app
WORKDIR /app
CMD ["hello.py", "/etc"]

then build and launch with an shell entrypoint:

$ docker build -t my_debug_image .
$ docker run --entrypoint=sh -ti my_debug_image

/app # ls
BUILD       Dockerfile  hello.py

Note: If the image you are using already has a tag, for example gcr.io/distroless/java17-debian11:nonroot, use the tag <existing tag>-debug instead, for example gcr.io/distroless/java17-debian11:nonroot-debug.

Note: ldd is not installed in the base image as it's a shell script, you can copy it in or download it.

Who uses Distroless?

If your project uses Distroless, send a PR to add your project here!

Community Discussion

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].