All insights DEVSECOPS · CONTAINERS

Distroless containers: what do they reduce, and what still needs securing?

A guide to Distroless: separating build from runtime, a nonroot user, dependency scanning, a pinned image and planning diagnostics without a shell.

What changes in the runtime image

The Distroless project provides runtime images that contain the application and the dependencies it needs, without the full operating environment you would expect in a standard Linux distribution. The project's standard images have no shell or package manager. That choice removes components the application does not need to run.

A smaller image does not make insecure code secure. A vulnerable dependency, an overly broad permission or an endpoint that accepts malformed input still needs to be addressed. So treat Distroless as one decision within runtime hardening, alongside application security and version management.

Separate build tooling from the runtime environment

In a multi-stage build, you install and run build tools in a separate stage and copy only what is needed into the runtime image. Before copying, check which files end up in the artifact: compiled code, runtime dependencies and static assets. Secret files, history and development tools are not automatically part of what you ship.

Pay attention to compatibility of the runtime, native libraries and CPU architecture. A successful build does not prove the application will run in the minimal image. Run the artifact and exercise a real path, including any file access or temporary writes the application needs to perform.

Define the runtime conditions too

Use a non-root user where the application allows it, plan for a read-only file system and limit capabilities and resources to what is needed. If the application must write, define a dedicated path with appropriate permissions. Restrictions applied without a runtime test can cause operational failures that are hard to pin down.

Networking and secrets also call for decisions. The container should have only the destinations and credentials it needs to do its job. There is no reason for a build-stage secret to remain inside the image. Walk through the path by which configuration and secrets reach the process at startup.

Plan diagnostics before you remove the shell

When the production image has no shell, diagnostics rely on logs, metrics, traces and the host environment's tooling. Write error messages that explain what failed without exposing secrets. Verify that a planned failure can be identified from the data you collect.

The project also offers debug variants, but there is no need to make them your regular production image. Define an investigation process in an approved, restricted environment. Do not add diagnostic tools to every image just because no other way of getting the information was planned.

Keep the hardening in place for the life of the product

Scan both the runtime image and the application dependencies. Record the base image and its version, and review updates as part of maintenance. Pinning a digest helps reproduce an artifact, but it requires a process that flags when the base needs updating.

  • The image is tested under runtime conditions similar to production.
  • It contains no secret files or unnecessary development dependencies.
  • There is a diagnostics path that does not require a shell in production.
  • Base image updates and scan findings have an owner.
From reading to working togetherDevOps, Cloud & Infrastructure

These guides were written with the help of AI tools. Examples are illustrative and do not describe client projects or results. Applying the recommendations requires a look at your system and needs.

About Bechor’s professional background
LET’S MAKE IT REAL

Let’s test this on your project.

Have an idea, a need or a question that hasn’t settled yet? Let’s work out together what’s right to do.

Let’s talk A direct conversation. A clear direction. A step that fits you.

Accessibility settings

Adjust the display to suit you. Settings run on your device and send nothing to anyone.

You can also zoom the site with your browser. Your device’s reduced-motion setting is always respected.

Accessibility statement & contact

Privacy & cookies

This site uses the Meta (Facebook) pixel to measure how well its advertising works: page views and messages sent. There are no other analytics tools. You can turn measurement off here at any time.

What is stored on your device
NamePurposeTypeDuration
bechor:accessibility:v1Remembers the accessibility settings you choseFunctional, at your requestUntil you delete it
bechor:privacy-notice:2026-10-25Remembers that you closed the privacy noticeEssentialUntil you delete it
bechor:ads-optoutRemembers that you turned ad measurement offEssential, at your requestUntil you delete it
_fbpMeta cookie that recognises the browser for ad measurementAdvertising and measurementUp to 90 days

Your preferences are kept only in your browser’s localStorage, are never sent to the server and contain nothing from the contact form. The _fbp cookie is created by the Meta pixel and is deleted when you turn measurement off.

Full privacy policy