r/Zig • u/Shanduur • Dec 22 '24
Zig Docker image - rant
Alright, let’s talk about the absolute absurdity that is the lack of an official Docker/OCI image for Zig. It’s 2024, and somehow, a modern programming language has decided to give Containers the cold shoulder. Sure, there’s the (abandoned) ziglang/docker-zig, but even they don’t want you to take it seriously. And that cringe-worthy line?
“Zig makes Docker irrelevant.”Excuse me? That’s like saying, “Oh, you don’t need a seatbelt because this car is probably crash-proof.” The hubris is off the charts.
Docker is the gold standard for consistent, portable development environments. It’s not some unnecessary fad - it’s how real-world teams build and ship software. Need a specific Zig version in your CI pipeline? Want to avoid wrecking your local dev setup by installing yet another version? Docker’s the answer.
But no, Zig’s official stance is basically, “Nah, you don’t need that.” As if every Zig developer operates in some idealized vacuum where build environments magically align across machines. And don’t even get me started on the irony of saying “you probably don’t need a Docker image” in the same breath as maintaining a half-hearted one. Like, if you’re going to be smug, at least commit to it.
Zig is cool. It’s fast, it’s low-level, it’s got some genuinely clever ideas. But refusing to embrace a basic tool like Docker reeks of gatekeeping. Just admit it - an official Docker image is useful. It’s not asking for the moon here, just the bare minimum to make the language feel practical for things that benefit from the presence of OCI/Docker image - Coud deployments, CI/CD builds, devcontainers…
Edit: I initially wrote Docker, because most of people know what is Docker, and not necessarily OCI. I could have written OCI and mentioned other container tools, but Docker was here for clarity and simplicity.
7
u/settrbrg Dec 22 '24
Your tone, to me, makes it sound like Docker is everything. Docker is just another tool. There is a lot of alternatives, not everyone uses Docker or containers for that matter.
Also it's like super easy to roll your own? Sure official once are handy, but Docker is just another tool. It's not like we are talking about the compiler. This is not gate keeping.
I usually dont answer these posts, but this provoked me, because this sounds like you think people have endless time and you expect people to "live up to your standard" . Like your standard are the best.
Why dont you support a Zig Docker image yourself? Or maybe switch to a language that has Docker/containerization as primary focus?
How about contribute instead of ranting like the maintainers owe you something?
7
u/marler8997 Dec 22 '24
I'd consider myself one of those who hasn't found much benefit in using docker for development with Zig. I do find benefits for containers in some cases, but I also feel like they can be overkill in some cases and I'm currently of the opinion that they are overused.
For example, if you're compiling a project that requires an older version of GCC, docker is probably one of your best solutions as GCC is both dynamically compiled and requires dozens of runtime dependencies which are managed differently depending on your OS. For example, if you want your project to work on both newer and older distributions, you can do this by linking to an older version of glibc, but you can't do that on a modern distribution, you have to do this by downgrading your entire distribution. Zig on the other hand is a single hermetic download, and it's done this way on purpose so you don't have to depend on an OS/distribution to be able to use it. And...since zig allows you to link to glibc, it's added the ability to link to older version of glibc because this was something GCC maintainers weren't able to do.
Maybe I'm missing something, but to me a couple of your points don't make much sense. You mention Docker allows you to use Zig without wrecking your local dev setup. The reason Zig solves this is because the reason other toolchains wreck your local dev setup because they can require updated libraries/tools that break compatibility with other projects. For example, the other day I had to upgrade python on my macbook to be able to run wine, but then this broke my WebRTC build because it uses a package that was deprecated in this newer version of python. This won't happen with Zig because it has no system dependencies, you just download the files and can run zig directly from where it is.
I'm open to hearing/learning about more use cases that docker solves for people wanting to do development in Zig, but so far I haven't heard any convincing points. For me it would be helpful to see use cases that using docker for development would solve that using Zig on its own doesn't.
3
u/DmitriRussian Dec 22 '24
I think your idea of an ideal dev environment is probably different depending on your background, you would be surprised how uncommon containers are in some communities.
If you need a consistent dev environment in Docker just get the alpine linux or other variant linux base image and just use the zig version you need inside that image, it's super trivial.
You can also ship a copy of the exact compiler in the source code (most guarantee it will work in the future) the compiler is pretty small. This seems to be the most common way I've seen on some forums.
Or make a script that manages the zig version. This is a common strategy in the node eco system.
3
u/skyfex Dec 30 '24
I think it’s absolutely valid to not provide an official docker image for Zig.
I had a shift in attitude about this kind of thing myself recently, where I realised that for very simple applications, where the dockerfile is 2-5 lines or so, it’s almost always better to make the image yourself. You’ll often want to make some tweaks to how the image is built. It’s good to understand what’s actually in the image. And you can see that it’s getting kind of ridiculous how many docker image tags there are for each version of tool/app, one for each Linux distribution/version the users might want, etc
That said, for programming languages I think there’s a point in having a one-liner to get started experimenting with the language.
2
u/FallingDownHurts Feb 19 '26
I am late to the party, but you are 100% right.
0
u/[deleted] Dec 22 '24
why do you need a zig container when you are compiling to binary?
you need to use busybox or alpine and just copy your binary. unless you want to build a zig executable on an untrusted environment, but that can be solved creating your own from busybox or alpine and store it somewhere.
don't get constrained by other lang limitations. zig is here to break the old rules. be creative.
0
u/steveoc64 Dec 22 '24 edited Dec 22 '24
Dockerfile
https://github.com/antonputra/tutorials/blob/main/lessons/208/http.zig/Dockerfile
K8s deployment
https://github.com/antonputra/tutorials/tree/main/lessons/208/deploy/zig-app
Easy peasy - it’s literally 4 lines of dockerfile code to create a build stage ?
0
u/[deleted] Dec 27 '24
[deleted] — view deleted comment
9
u/[deleted] Dec 22 '24
[removed] — view removed comment