Interview Prep/Docker/Image Security & Hardening

What is the safe way to use `ADD` or `curl | sh` in a Dockerfile?

BeginnerProductionImage Security & Hardening
Answer

Verify checksums or signatures of anything downloaded. Prefer ADD --checksum=sha256:... https://... or curl followed by sha256sum -c. Never curl | sh without pinning a version and hash. Pin versions via ARG TOOL_VERSION and fetch from official releases.

ADD --checksum=sha256:ab12... https://example.com/tool-1.2.3-linux-amd64.tar.gz /tmp/
All Docker questions Roadmap: Docker & containers

More on Image Security & Hardening