-
Notifications
You must be signed in to change notification settings - Fork 517
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
using buildpack-deps to build images - bigger images, increased attack surface #427
Comments
Python is from buildpack-deps. Having a consistent base image across all the language-stack images streamlines the build process for updates and changes |
Yes, I've already thought of the multi-staging setup with go where you can simply copy your binary. And that solves most of the issues, indeed. I wonder though where this general consensus comes from. I bet people use these images directly in production as such and don't worry too much about it, because they know they're official and they think it's the best they get directly for production purposes. I'm sure I'm not the only one who assumes this. I and many others have used postgresql, mysql, python and other images directly as such. And I might not have enough experience, but many others that I know do, and they're still using it. So I'd assume someone isn't really getting their message across :) I'm guessing postgresql, for instance, doesn't fall into the same category as golang and other programming languages in this context? |
Yeah the other repo's don't fall into the same category as this particular one. Obviously there's a tremendous number of great usecases for using the Official Images in production and testing, but for this repo we see that the general consensus with is this typically wouldn't be used as a runtime base. That's why it's based on All the images you listed have |
Thanks for pointing me to the docs. This is probably getting out of scope, but regarding nodejs, for instance, I don't think people should use the defacto image with python preinstalled as described in the latter case (production image based on it, so not as a multi-staged setup), as the author suggests here. I think it kind of borders on bloatware in my humble opinion.
and:
But I see how this can get ambiguous and interpretable. I guess I simply expected something different here. Thanks for your replies. [Later edit:] Only afterwards did I see that the same text (first paragraph) is used also for the golang image. |
In this case specifically, we're only plus |
If you want a slimmer alternative (that's still Debian-based or even Ubuntu-based), something like the following should work pretty reasonably: FROM debian:bullseye-slim
ENV PATH /usr/local/go/bin:$PATH
COPY --from=golang:1.18-bullseye /usr/local/go /usr/local/go |
Yeah, I got all that, I mentioned in the first post that python is a dependency of mercurial. |
Yeah, I think this is more a documentation adjustment than a change to the image. Users should be using the The Alpine-based images could maybe be used for production since they include less tools in the final images, but even then the go compiler itself could be considered a potential attack tool (or
|
I think it would be great to have a For teams such as ours who, are running their own CI agents, the Go image will be something we need to pull down and store on our CI servers and may also be used as a base for other build images that include further tools and such. Here are some examples comparing size differences between normal and slim variants for some other languages:
The Alpine variant is not optimal for projects that prefer Debian (which is more consistently the base OS choice for all official Docker images). Huge thanks |
Background:
Official Images FAQ:
Since our build system makes heavy use of Docker build cache, just rebuilding the all of the Dockerfiles won't cause any change. So we rely on periodic base image updates.
So, There is one package update available and it will be automatically applied when the images are rebuilt with the next Debian base image update (likely about 2-3 weeks from now): $ docker run -it --rm --pull=always buildpack-deps:bullseye-scm
bullseye-scm: Pulling from library/buildpack-deps
Digest: sha256:ca9b375648e50b4c26007c99cb7dca68626fc42863c01841d7232f41e166130e
Status: Image is up to date for buildpack-deps:bullseye-scm
root@2ebb96764ffc:/# apt update
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [234 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
Fetched 8640 kB in 1s (6932 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
root@2ebb96764ffc:/# apt list --upgradable
Listing... Done
libapr1/stable-security 1.7.0-6+deb11u2 amd64 [upgradable from: 1.7.0-6+deb11u1]
N: There is 1 additional version. Please use the '-a' switch to see it
root@2ebb96764ffc:/# No kernel is installed in the image: root@2ebb96764ffc:/# apt-cache pkgnames | grep linux-image
root@2ebb96764ffc:/# apt install linux-image-amd64
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apparmor busybox cpio firmware-linux-free initramfs-tools
initramfs-tools-core klibc-utils kmod libklibc libkmod2 linux-base
linux-image-5.10.0-21-amd64 pigz udev
Suggested packages:
apparmor-profiles-extra apparmor-utils libarchive1 bash-completion
linux-doc-5.10 debian-kernel-handbook grub-pc | grub-efi-amd64 | extlinux
The following NEW packages will be installed:
apparmor busybox cpio firmware-linux-free initramfs-tools
initramfs-tools-core klibc-utils kmod libklibc libkmod2 linux-base
linux-image-5.10.0-21-amd64 linux-image-amd64 pigz udev
0 upgraded, 15 newly installed, 0 to remove and 1 not upgraded.
Need to get 58.9 MB of archives.
After this operation, 333 MB of additional disk space will be used.
Do you want to continue? [Y/n] ^C |
This has been fixed in Docker Scout's results. 👍 |
I think the discussion here is probably as sufficiently "resolved" as this issue is going to be. To summarize, use of this image as a base is a case of the classic "security vs usability teeter-totter" and leaning more towards the right-hand side of that equation (which is also why most of our images also include a slimmer variant to avoid it, such as |
I'm just wondering, maybe I'm missing something, but is using buildpack-deps actually a good idea?
I've done a short test to compare the image sizes of the official golang versus installing golang starting from plan debian and the difference is quite significant (756MB vs 460MB).
What also surprised me is that python is also installed - which is actually a dependency of mercurial. Is this actually necessary when running go? Is there a reasoning behind this?
Thanks!
The text was updated successfully, but these errors were encountered: