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/
More on Image Security & Hardening
Why should containers not run as root, and how do you enforce it?BeginnerWhat is a distroless image and what are the trade-offs?BeginnerHow do you scan an image with Trivy and fail a CI build on serious findings?BeginnerHow do you manage Trivy false positives and accepted risks?IntermediateWhich `docker run` flags make up a hardened runtime baseline?BeginnerWhat does `no-new-privileges` protect against?Beginner