-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"FROM scratch" image #310
"FROM scratch" image #310
Conversation
I just want to point out that alpine-based NGINX image is 16 MB |
It's not just about size. Attack surface is |
Alright! I just fixed the aforementioned issue with name resolving, I've now commited a fully-working version (as far as I can tell) of this PR's scratch Dockerfile. I also removed duplicated system libraries, caused by following symlinks during the Docker build process. Summary
If you were to
Notes
You can try the image at ricardbejarano/nginx:1.15.8. |
How so? This image still contains the same set of libraries: glibc, openssl, zlib and so on, although they're now compiled statically instead of being linked as shared objects (which, perhaps, creates an illusion of zero attack surface). I personally don't see how this is different from a regular nginx image built with |
It's a very common issue to pack applications with full-blown operating systems in Docker images, but that is an anti-pattern. Using OS's as base images should only be done during development, just in case there's some dependency you lost track of. I'm not saying there's zero attack surface, but if, for some reason, someone where to break out of NGINX, I'd rather not give him/her Distroless base images exist for a reason. If you go to https://hub.docker.com/_/nginx/scans/library/nginx/mainline (you must login, or else it'll 404 you), you will see a summary of an automatic vulnerability scan in the latest Based on that summary, the image contains 2 "critically" vulnerable binaries, To be fair, this image compiles NGINX in |
UPDATE: I built a Get more information about |
|
@yosifkit pretty much described what I wanted to write. Closing this PR as this is not something we will merge. |
This is a Dockerfile for a
FROM scratch
Docker image of NGINX.It includes only the required files, libraries and a statically-compiled NGINX binary with built-from-source PCRE, ZLIB and OPENSSL libraries.
The overall image size as of
1.15.8
is~18.1MB
.I hope it helps to start a discussion about moving to built-from-source dependencies and NGINX during build time.
ricardbejarano/nginx
is a very similar Dockerfile, only with Brotli support included, which I removed here because you do not include it on your images.You can try it out by running the
ricardbejarano/nginx:1.15.8
Docker Hub image.