3 ms·
Docker's concept of base images is quite useful. You can build your application in a convenient container, then copy the resulting binary into a container with
by jrockway 8y ago
Docker's concept of base images is quite useful. You can build your application in a convenient container, then copy the resulting binary into a container with nothing else (except SSL certificates and the time zone database, for Go code anyway).
https://gist.github.com/jrockway/cceef8bb5dcef62743f8bcbc044cd2ad https://gist.github.com/jrockway/cceef8bb5dcef62743f8bcbc044...
I started doing this around the time we started doing vulnerability scanning and now the containers are both tiny and free of scannable security issues. I recommend that others take this approach if possible, as having too much stuff in your container increases app startup time, storage costs, and your attack surface.
- curtis 8y agoI've been doing something similar, but I've been taking it one step further: Alpine's apk package manager will let you treat a subdirectory as "root" and you can install packages there. Then you can write the root out as a tar file and use that as the file system for a "FROM scratch" Docker build. One deficiency is that every package seems to depend on the Busybox shell, so the only way to get rid of that is to delete it after it's installed. So far this approach seems to work OK, but it feels unnecessarily hacky, and I wish there was better tool support for this kind of thing.