scratch
Docker's special empty base image, with no files at all, used to ship a single static binary and nothing else.
In more detail
An image built FROM scratch contains only what you copy in, so it has no shell, no package manager and no certificates or time zone data. That makes it tiny and leaves almost nothing to attack, but you cannot exec into it to debug. Copy in CA certificates if the program makes HTTPS calls.
Example
FROM scratch
COPY --from=build /out/app /app
ENTRYPOINT ["/app"]Related terms
- static binary — A program file that carries all the code it needs inside it and loads no shared libraries from the machine it runs on.
- minimal base image — A base image with as little inside as possible, such as Alpine, a slim variant or a distroless image, to shrink size and attack surface.
- multi-stage build — A Dockerfile with several FROM stages, where later stages copy only what they need from earlier ones.
- TLS certificate — A signed digital document that proves a server really owns a domain name and holds the key used to start encrypted TLS connections.
- base image — The image a Dockerfile starts from with FROM, which supplies the operating system files and often a language runtime.
Taught in
- Shipping in Scratch and Distroless Images — Concurrent Systems Programming with Go
- Containerizing and Testing the Final Build — Concurrent Systems Programming with Go