News for hackers. Stuff that matters.
Re:Ask HN: Who operates at scale without containers? by barbazoo on Tuesday March 22, 2022 @12:53PM (#30768496)
> Containers only give reproducible deployments, not builds

Could someone elaborate on this please? Doesn't it depend entirely on your stack how reproducible your build is? Say I have a Python app with its OS level packages installed into a (base) image and its Python dependencies specified in a Pipfile, doesn't that make it pretty reproducible?

Is the weak spot here any OS dependencies being installed as part of the continuous build?

Re:Ask HN: Who operates at scale without containers? by smilliken on Tuesday March 22, 2022 @02:15PM (#30769482)
You already got a few good answers, but I'll echo them: you can do reproducible builds in containers, and nothing's stopping you from using nix inside containers. But you're at the mercy of all the different package managers that people will end up using (apt, npm, pip, make, curl, etc). So your system is only as good as the worst one.

I inherited a dozen or so docker containers a while back that I tried to maintain. Literally none of them would build— they all required going down the rabbit hole of troubleshooting some build error of some transitive dependency. So most of them never got updated and the problem got worse over time until they were abandoned.

The reason Nix is different is because it was a radically ambitious idea to penetrate deep into how all software is built, and fix issues however many layers down the stack it needed to. They set out to boil the ocean, and somehow succeeded. Containers give up, and paper over the problems by adding another layer of complexity on top. Nix is also complex, but it solves a much larger problem, and it goes much deeper to address root causes of issues.

Re:Ask HN: Who operates at scale without containers? by jka on Tuesday March 22, 2022 @04:27PM (#30771069)
Do your developers run the same Nix packages that you deploy to production?

(that sounds like a energy-level-transition in developer productivity and debugging capability, if so)

Re:Ask HN: Who operates at scale without containers? by smilliken on Tuesday March 22, 2022 @04:40PM (#30771219)
Yeah, the environment is bit-for-bit identical in dev and prod. Any difference is an opportunity for bugs.

OK, there's one concession, there's an env var that indicates if it's a dev and prod environment. We try to use it sparingly. Useful for stuff like not reporting exceptions that originate in a dev environment.

Basically, there's a default.nix file in the repo, and you run nix-shell and it builds and launches you into the environment. We don't depend on anything outside of the environment. There's also a dev.nix and a prod.nix, with that single env var different. There's nothing you can't run and test natively, including databases.

Oh, it also works on MacOS, but that's a different environment because some dependencies don't make sense on MacOS, so some stuff is missing.

Re:Ask HN: Who operates at scale without containers? by jka on Tuesday March 22, 2022 @07:59PM (#30773189)
That sounds extremely impressive, thank you. I hope to find some time to try out Nix soon (appending it to the list of technologies to learn...).
Re:Ask HN: Who operates at scale without containers? by kazinator on Tuesday March 22, 2022 @08:46PM (#30773514)
Does that mean you turn off security-related randomizations in everything, like address space randomization and hash table randomization?
Re:Ask HN: Who operates at scale without containers? by smilliken on Tuesday March 22, 2022 @11:42PM (#30774675)
No, we have address space randomization and hash table randomization since those happen at runtime. /dev/random works as you'd expect.

The immutability is just at build time. So chrome and firefox aren't able to seed a unique ID in the binaries like you might be accustomed to. Funny story, we had a python dependency that would try to update itself when you imported it. I noticed because it would raise an exception when it was on a read only mount.

Re:Ask HN: Who operates at scale without containers? by Gwypaas on Tuesday March 22, 2022 @05:09PM (#30771596)
How do you manage quick iteration loops?
Re:Ask HN: Who operates at scale without containers? by smilliken on Tuesday March 22, 2022 @11:47PM (#30774701)
We use python. If we were writing in a compiled language, we'd use the same compiler toolchain as everyone else, but with the versions of all of our dependencies exactly the same from nix. We have some c extensions and compile Typescript and deploy those build artifacts. In the case of javascript, our node modules is built by nix, and our own code is built by webpack --watch in development.
Re:Ask HN: Who operates at scale without containers? by nunez on Tuesday March 22, 2022 @03:38PM (#30770496)
I don't know Nix and can't comment on that, but in my experience, when I've inherited containers that couldn't build, this was usually due to its image orphaned from their parent Dockerfiles (i.e. someone wrote a Dockerfile, pushed an image from said Dockerfile, but never committed the Dockerfile anywhere, so now the image is orphaned and unreproducable) or due to the container being mutated after being brought up with `docker exec` or similar.

Assuming that the container's Dockerfile is persisted somewhere in source control, the base image used by that Dockerfile is tagged with a version whose upstream hasn't changed, and that the container isn't modified from the image that Dockerfile produced, you get extremely reproducable builds with extremely explicit dependencies therein.

That said, I definitely see the faults in all of this (the base image version is mutable, and the Dockerfile schema doesn't allow you to verify that an image is what you'd expect with a checksum or something like that, containers can be mutated after startup, containers running as root is still a huge problem, etc), but this is definitely a step up from running apps in VMs. Now that I'm typing this out, I'm surprised that buildpacks or Chef's Habitat didn't take off; they solve a lot of these problems while providing similar reproducability and isolation guarantees.

Re:Ask HN: Who operates at scale without containers? by tonyarkles on Tuesday March 22, 2022 @05:33PM (#30771855)
So as a quick example from my past experiences, using an Ubuntu base image is fraught. If you don't pin to a specific version (e.g. pinning to ubuntu:20.04 instead of ubuntu:focal-20220316), then you're already playing with a build that isn't reproducible (since the image you get from the ubuntu:20.04 tag is going to change). If you do pin, you have a different problem: your apt database, 6 months from now, will be out of date and lots of the packages in it will no longer exist as that specific version. The solution is "easy": run an "apt update" early on in your Dockerfile... except that goes out onto the Internet and again becomes non-deterministic.

To make it much more reproducible, you need to do it in two stages: first, pinning to a specific upstream version, installing all of the packages you want, and then tagging the output image. Then you pin to to that tag and use that to prep your app. That's... probably... going to be pretty repeatable. Only downside is that if there is, say, a security update released by Ubuntu that's relevant, you've now got to rebuild both your custom base and your app, and hope that everything still works.

Re:Ask HN: Who operates at scale without containers? by nunez on Wednesday March 23, 2022 @12:50AM (#30775070)
Yup, that can, indeed, be a problem. Relying on apt (for example) is generally a bad idea, hence why you'd want to vendor everything that your app needs if a specific version of, say, libcurl is something that your app requires.

This along with the supply chain issues you mentioned is why some maintainers are moving towards using distroless base images instead, though these can be challenging to debug when things go wrong due to them being extremely minimal, down to not having shells.

Re:Ask HN: Who operates at scale without containers? by hinkley on Tuesday March 22, 2022 @02:04PM (#30769358)
This is something that even the Docker core team is not entirely clear on (either they understand it and can't explain it, or they don't understand it).

The RUN command is Turing complete, therefore cannot be idempotent. Nearly every usable docker image and base image include the RUN command, often explicitly to do things that are not repeatable, like "fetch the latest packages from the repository".

This is all before you get to application code which may be doing the same non-repeatable actions with gems or crates or maven or node modules, or calling a service and storing the result in your build. Getting repeatable docker images usually is a matter of first getting your build system to be repeatable, and then expanding it to include the docker images. And often times standing up a private repository so you have something like a reliable snapshot of the public repository, one you can go back to if someone plays games with the published versions of things.

Re:Ask HN: Who operates at scale without containers? by meatmanek on Tuesday March 22, 2022 @03:00PM (#30770062)
pedantic nit-pick that doesn't detract from your main point: Turing completeness doesn't imply that it can never be idempotent. In fact we'd expect that a particular Turing machine given a particular tape should reliably produce the same output, and similarly any Turing-complete program given the exact same input should produce the exact same output. Turing machines are single-threaded, non-networked machines with no concept of time.

The main reason the RUN statement isn't idempotent, in my opinion, is that it can reach out to the network and e.g. fetch the latest packages from a repository, like you mention. (Other things like the clock, race conditions in multi-threaded programs, etc. can also cause RUN statements to do different things on multiple runs, but I'd argue those are relatively uncommon and unimportant.)

Re:Ask HN: Who operates at scale without containers? by dilyevsky on Tuesday March 22, 2022 @04:46PM (#30771309)
Yup, the problem is not that RUN is Turing Complete the problem is that it’s non-hermetic.
Re:Ask HN: Who operates at scale without containers? by hinkley on Thursday March 24, 2022 @03:08PM (#30794115)
If it's Turing Complete you can't prove that it's hermetic. You can't even prove if it'll ever finish running (halting problem).

Maybe someday someone will invent a sort of EBPF for containers, but usually the first batch of RUN commands and the last are calling package managers, and in between you're doing things like creating users and setting permissions using common unix shell commands, which have the same problems.

With the possible exception of the unix package managers, we have no hope of those ever being rewritten inside of a proof system, because the package manager is often a form of dogfooding for the language community. The Node package manager is going to be written in Node and use common networking and archive libraries. Same for Ruby, Rust, you name it.

Re:Ask HN: Who operates at scale without containers? by dilyevsky on Friday March 25, 2022 @04:18PM (#30806637)
> If it's Turing Complete you can't prove that it's hermetic

Turing Machine model doesn’t apply to i/o so it is a meaningless statement.

Bazel and Nix achieve this by sandboxing i/o no turing incompleteness needed (tho bazel is still purposely non-tc but for totally different reason than hermeticity)

Re:Ask HN: Who operates at scale without containers? by treis on Tuesday March 22, 2022 @05:23PM (#30771756)
>Getting repeatable docker images

But there's no real need for repeatable build docker images. You copy the image and run it where ever you need to. The entire point of Docker is to not have to repeat the build.

Re:Ask HN: Who operates at scale without containers? by hinkley on Tuesday March 22, 2022 @06:11PM (#30772242)
If you could explain that to the Docker team you would be performing a great humanitarian service.

They for many years close issues and reject PRs based on the assertion that Dockerfile output needs to be repeatable (specifically, that the requested feature or PR makes it not repeatable). It’s not, it can’t be without a time machine, and if it was I believe you’d find that ace icing traction would have been more difficult, even impossible.

Re:Ask HN: Who operates at scale without containers? by treis on Tuesday March 22, 2022 @07:21PM (#30772895)
Do you have an example?
Re:Ask HN: Who operates at scale without containers? by spion on Tuesday March 22, 2022 @09:08PM (#30773677)
Until there is a critical vulnerability in one of the components present on that image (system packages or application packages).
Re:Ask HN: Who operates at scale without containers? by kronin on Wednesday March 23, 2022 @12:17AM (#30774885)
This is why I haven't adopted the practice of "Build your artifact along with the docker image that packages it".

Instead, build your artifact and publish it to an artifact repository, just like we used to.

_then_ wrap that artifact in a Docker image.

Vulnerability found in the docker image? No problem. Build a new image with the same artifact.

Re:Ask HN: Who operates at scale without containers? by barbazoo on Thursday March 24, 2022 @01:49PM (#30793206)
I'm curious why you're being downvoted for this. Whoever disagrees, please share some context.

What you said about "wrapping" I interpret as: based on an image for instance with OS level dependencies you create another image with application level artifacts, e.g. a python application. When your app changes, you don't build the base image again, you only build the app image. This makes sense to me.

Re:Ask HN: Who operates at scale without containers? by treis on Wednesday March 23, 2022 @10:45AM (#30778969)
At that point you're not repeating a build. You're building a new image.
Re:Ask HN: Who operates at scale without containers? by spion on Wednesday March 23, 2022 @11:42AM (#30779642)
From that point on, the build may become "fully unrepeatable" because previous steps may have reused cached stuff that can no longer be reproduced.

You could break the build simply by cleaning some things from the cache, without changing the Dockerfile, even thought that Dockerfile "succeeded to build"

Re:Ask HN: Who operates at scale without containers? by convolvatron on Wednesday March 23, 2022 @01:38PM (#30781107)
what happens when you need to create a new one with a small incremental change?
Re:Ask HN: Who operates at scale without containers? by jffry on Tuesday March 22, 2022 @01:06PM (#30768677)
> Containers only give reproducible deployments, not builds

I think that means containers alone are insufficient for creating reproducible builds, not that containers make reproducible builds impossible.

Re:Ask HN: Who operates at scale without containers? by lazide on Tuesday March 22, 2022 @01:59PM (#30769306)
I believe that is correct. It’s also hard to make container builds really reproducible (even with other parts of the build being so). Some sibling comments have talked about why.

Containers are to ops like C is to programming languages. Man is it useful, but boy are there footguns everywhere.

Usually still better than the ops equivalent of assembly, which is what came before though - all the custom manual processes.

Kubernetes is maybe like early C++. A bit weird, still has footguns, and is it really helping? Mostly it is in most cases, but we’re also discovering many more new failure modes and having to learn some new complex things.

As it matures, new classes of problems will be way easier to solve with less work, and most of the early footguns will be found and fixed.

There will be new variants that hide the details and de-footgun things too, and that will have various trade offs.

No idea what will be the equivalent of Rust or Java yet.

Re:Ask HN: Who operates at scale without containers? by thinkharderdev on Tuesday March 22, 2022 @02:34PM (#30769717)
I love this analogy
Re:Ask HN: Who operates at scale without containers? by thinkingkong on Tuesday March 22, 2022 @01:11PM (#30768731)
The dependencies can change out from underneath you transparently unless you pin everything all the way down the stack. Upstream docker images for example are an easy to understand vector of change. The deb packages can all change minor versions between runs, the npm packages (for example) can change their contents without making a version bump. Theres tons of implicit trust with all these tools, build wise.
Re:Ask HN: Who operates at scale without containers? by Osiris on Tuesday March 22, 2022 @01:36PM (#30769031)
npm packages can change without a version change?

Can you explain this?

npm doesn't allow you to delete any published versions (you can only deprecate them). You aren't allowed to publish a version that's already been published.

Even when there have been malicious packages published the solution has been to publish newer versions of the package with the old code. There's no way to delete the malicious package (maybe npm internally can do it?).

Re:Ask HN: Who operates at scale without containers? by thinkingkong on Tuesday March 22, 2022 @01:47PM (#30769178)
Sorry, without a minor version change. You can easily publish a patch version and most people don't pin that part of their dependency.
Re:Ask HN: Who operates at scale without containers? by LunaSea on Tuesday March 22, 2022 @02:01PM (#30769328)
They don't need to pin it directly.

They only need to "npm ci" (based on package-lock.json) instead of "npm install" (based on package.json) within the Docker container to get a fully reproducible build.

Re:Ask HN: Who operates at scale without containers? by pojzon on Wednesday March 23, 2022 @04:21AM (#30776237)
Tbh I hope ppl do pin stuff to specific versions and have their own repositories of packages because you dont want to have external dependencies during builds that can fail.

DevOps 101 more or less..

Re:Ask HN: Who operates at scale without containers? by monocasa on Tuesday March 22, 2022 @12:56PM (#30768532)
I think that's what they're saying, that containers are orthogonal to reproducible builds.
Re:Ask HN: Who operates at scale without containers? by q_eng_anon on Tuesday March 22, 2022 @01:59PM (#30769307)
https://github.com/GoogleContainerTools/distroless

This is the container community’s response to this ambiguity I think.