TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: dockerc – Docker image to static executable "compiler"

374 pointsby NilsIRLabout 1 year ago

41 comments

chaxorabout 1 year ago
This is really great.<p>I have been trying to get my docker to be more distributable. Right now it&#x27;s just a simple python script in a python env inside a docker container inside a QEMU container to automate a click and then netcat something.<p>Pretty sweet. It&#x27;s only like 20GB, so pretty lightweight by modern standards.
评论 #39626606 未加载
评论 #39634668 未加载
评论 #39627428 未加载
rnts08about 1 year ago
I absolutely love how we are going full circle to portable executable binaries but with embedded OS. Taking the whole &quot;it works on my machine&quot; to a whole new level of troubleshooting hell.<p>Awesome project though.
评论 #39627203 未加载
评论 #39627388 未加载
评论 #39649693 未加载
stauntonabout 1 year ago
I can&#x27;t wait for people to start sending me dockerfiles that run these things, made from docker containers that run more of these things...
评论 #39625136 未加载
评论 #39625402 未加载
pxcabout 1 year ago
In the past I&#x27;ve used and recommended nix-bundle¹ or its first-party counterpart `nix bundle`² for this. That lets you skip the step of managing the creation of the Docker image, which is nice.<p>I suppose dockerc could be convenient when you already have a Docker image on hand, especially if it was a PITA to create or its creation is a lost art.<p>Besides fat executables, `nix bundle` also lets you create Docker images, AppImages, and images&#x2F;executables in a few other formats.<p>--<p>1: <a href="https:&#x2F;&#x2F;github.com&#x2F;matthewbauer&#x2F;nix-bundle">https:&#x2F;&#x2F;github.com&#x2F;matthewbauer&#x2F;nix-bundle</a><p>2: <a href="https:&#x2F;&#x2F;nixos.org&#x2F;manual&#x2F;nix&#x2F;unstable&#x2F;command-ref&#x2F;new-cli&#x2F;nix3-bundle.html" rel="nofollow">https:&#x2F;&#x2F;nixos.org&#x2F;manual&#x2F;nix&#x2F;unstable&#x2F;command-ref&#x2F;new-cli&#x2F;ni...</a>
dvfjsdhgfvabout 1 year ago
The Reddit screenshot is hilarious. But it reflects my feelings whenever I want to install a product made by many of these self-proclaimed &quot;open source&quot; companies that bend over backwards to make it almost impossible to install the open version (...and often to discover the crucial features are missing anyway).
评论 #39621733 未加载
评论 #39621736 未加载
strangemonadabout 1 year ago
There is some great cosmic irony here. A section about never needing to build, install, etc… just give me an executable. Followed immediately with an incantation for zig to build this project
评论 #39627044 未加载
dflockabout 1 year ago
Nice idea! How does this actually work? I&#x27;m guessing it&#x27;s wrapping a custom loader + docker + the image into an executable binary - or something like that?
评论 #39621573 未加载
评论 #39624655 未加载
syrusakbaryabout 1 year ago
This is awesome Nils! So happy to see the progress on the project since we chatted on the AGI house :) (I&#x27;m Syrus, from Wasmer)<p>dockerc works by using: Zig + crun + squashfs&#x2F;overlayfs. Nils (the author) posted a bit more in this thread for anyone interested: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39621573">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=39621573</a>
Alifatiskabout 1 year ago
So what does this mean? That I can finally ship portable Ruby executable without requiring the end user to install Ruby?
评论 #39621939 未加载
评论 #39622831 未加载
评论 #39637574 未加载
jbverschoorabout 1 year ago
You&#x27;ll still need different ones for different architectures...<p>At this point you might as well compile statically and include a virtual filesystem. Pretty much what Sun created in the 90s..
评论 #39649702 未加载
throwitaway222about 1 year ago
Awesome use of that rant pic.<p>Next rant pic- When I RUN a F*ING EXE it should open a Window with the application in it you smelly nerds!!!!
评论 #39624486 未加载
评论 #39624982 未加载
评论 #39626083 未加载
Cu3PO42about 1 year ago
Let me start by saying this looks like a fun project to work on and, honestly, that&#x27;s reason enough for doing it.<p>As a solution to the problem of app distribution, I do have some concerns, though:<p>How do you deal with resource sharing? This starts with just filesystem mounts, but also concerns ports, possibly devices, and probably many other things I&#x27;m forgetting. Is this somehow configurable?<p>How does this compare to AppImage? IIRC that also puts everything into a squashfs.<p>If a user without CAP_SYS_USER_NS executes one of the binaries built by dockerc, do you handle that gracefully in any way?
评论 #39623392 未加载
luke-stanleyabout 1 year ago
What about Cosmopolitan and WASM? ;)<p>Cosmopolitan libc allows compiling of a single binary that runs on multiple OS platforms without modification – maybe Dockerc could use this to create a more universally portable container binary?<p>WASM binaries could run in the browser, or another WASM VM, including securely sandboxed environments that spin up fast.<p>I understand that newer Docker builds can use WASM under the hood so WASM in WASM would be funny, it seems if that were the case, maybe extracting the WASM with a more thin wrapper would be better?
评论 #39628393 未加载
politelemonabout 1 year ago
OK that&#x27;s a cool idea. I did try the example in the README but I get an error right away (Ubuntu 22.04)<p>-----<p>$ .&#x2F;dockerc --image docker:&#x2F;&#x2F;oven&#x2F;bun --output bun<p>FATA[0000] Error loading trust policy: open &#x2F;etc&#x2F;containers&#x2F;policy.json: no such file or directory ⨯ open CAS: validate: read oci-layout: invalid image detected Cannot stat source directory &quot;&#x2F;tmp&#x2F;dockerc-fbObho&#x2F;bundle&quot; because No such file or directory error: FileNotFound<p>-----<p>Btw does this also solve the last line in the original user&#x27;s complaints?
评论 #39621815 未加载
FooBarWidgetabout 1 year ago
It&#x27;s interesting. According to the source code, it uses FUSE to mount the container&#x27;s internal filesystem. This means that the compiled binary will either need root privileges to run, or the user must have configured FUSE to allow non-root mounting. Not ideal, but there&#x27;s not much of an alternative either.
评论 #39628211 未加载
nicoabout 1 year ago
This is incredibly cool!<p>Currently using docker as a way to easily distribute and run an open project[1], this would be great to use on top of docker<p>Will this run ok on a Mac? (I see the feature is pending, any tests done yet?)<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;nicobrenner&#x2F;commandjobs">https:&#x2F;&#x2F;github.com&#x2F;nicobrenner&#x2F;commandjobs</a>
评论 #39624759 未加载
tutfbhufabout 1 year ago
I think a straightforward way to achieve this would be to place a Docker image as a binary directly into a statically compiled podman (<a href="https:&#x2F;&#x2F;github.com&#x2F;mgoltzsche&#x2F;podman-static">https:&#x2F;&#x2F;github.com&#x2F;mgoltzsche&#x2F;podman-static</a>).
kunleyabout 1 year ago
This can be useful for certain people, but I am surprised the documentation (there is just the Readme) doesn&#x27;t mention what happens when you already have a docker daemon- esp. what happens to all the networking&#x2F;firewall tricks docker is using. I see potential for quite a number of operational issues.<p>Nice to see Zig in action, btw. What about using Zon for deps, instead of a git submodule? Just curious if the author tried it, I honestly didn&#x27;t have time to use Zon deps yet
评论 #39628145 未加载
bartekpaciaabout 1 year ago
Very cool project! Can’t wait to see its future development.<p>I’m glad that I know the author. He won 2 tracks of this year’s Stanford TreeHacks with it:)
flaminHotSpeedoabout 1 year ago
Might be worth calling out that it supports any OCI images, which seems to be the case from a quick skim throught the repo!
hiatusabout 1 year ago
Curious about the choice of Zig, any specific reason for using it?
评论 #39624818 未加载
评论 #39622059 未加载
mmh0000about 1 year ago
This sounds really cool, but, doesn&#x27;t work for me, on version 0.2.1:<p><pre><code> $ .&#x2F;dockerc --image docker:&#x2F;&#x2F;docker.io&#x2F;pivotalrabbitmq&#x2F;perf-test --output yourmom $ .&#x2F;yourmom 2024-03-07T03:10:54.145333Z: chown `&#x2F;dev&#x2F;pts&#x2F;0`: Invalid argument</code></pre>
评论 #39625327 未加载
评论 #39624740 未加载
moss2about 1 year ago
Have we come full circle? Docker was made to create a stable environment for an executable to be run in. Now we&#x27;re making executables out of the stable environment... should we run that executable in a docker image too?
nikisweetingabout 1 year ago
Damn I would really love to distribute ArchiveBox this way, been looking for a solution that does this for years. Crossing my fingers for arm64&#x2F;macoOS support someday!
zubairqabout 1 year ago
I&#x27;m going to try this to make my app an exe. As great as Docker is, most users do not care to install Docker just to run my app.
up2isomorphismabout 1 year ago
Ahhh, this is one of those situation where &quot;you can does not mean you should&quot;. One does this likely because he want to distribute the binary, but turning whatever inside a docker container in a gigantic blob can gives more trouble down the road.
just_testingabout 1 year ago
This is so freaking insane! I love it!
Zambyteabout 1 year ago
&gt; Usage: Install dockerc from the latest release.<p>I love the juxtaposition with the image directly above this
KomoDabout 1 year ago
Okay, that is interesting and cool, though I assume the binaries will be pretty large
评论 #39622813 未加载
dale_glassabout 1 year ago
Nice, but what&#x27;s the difference between this and AppImage?
评论 #39628168 未加载
misnomeabout 1 year ago
Same thing as Apptainer&#x2F;Singularity? Or a different approach?<p>I always remember having issues using the Singularity outputs for anything that needed to interact with the filesystem.
评论 #39624987 未加载
winwangabout 1 year ago
Kind of reminds me of a unikernel.
deeteeceeabout 1 year ago
lol I feel that man&#x27;s rage. I&#x27;ve shouted the same lines while trying out a new tool
Orasabout 1 year ago
I think it’s a great idea, but what kind of file size range should I expect?
评论 #39622184 未加载
tluyben2about 1 year ago
Can it be done for docker compose (in theory) too?
评论 #39628182 未加载
anon115about 1 year ago
XDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
k8svetabout 1 year ago
Folks will literally shove a container runtime, FUSE, and operating system image into a binary to avoid going to thera... learning Nix.
评论 #39622299 未加载
评论 #39622617 未加载
评论 #39625183 未加载
评论 #39622599 未加载
nightshift1about 1 year ago
Can I run this in a container?
评论 #39625030 未加载
评论 #39623981 未加载
lyeagerabout 1 year ago
Enroot can do something similar: <a href="https:&#x2F;&#x2F;github.com&#x2F;NVIDIA&#x2F;enroot&#x2F;blob&#x2F;v3.4.1&#x2F;doc&#x2F;cmd&#x2F;bundle.md">https:&#x2F;&#x2F;github.com&#x2F;NVIDIA&#x2F;enroot&#x2F;blob&#x2F;v3.4.1&#x2F;doc&#x2F;cmd&#x2F;bundle....</a>
评论 #39624880 未加载
评论 #39623512 未加载
astreaabout 1 year ago
I think this is a cute side project but as an actual piece of a company’s stack this just screams antipattern
评论 #39624858 未加载
评论 #39624337 未加载
ryukopostingabout 1 year ago
The README indicates that this tool will only support Windows and MacOS through emulation. I find that odd.<p>Let&#x27;s face it, if you&#x27;re using Linux, you&#x27;re comfortable typing some stuff into the terminal to install software. Or if you aren&#x27;t comfortable with it yet, you will be soon. That&#x27;s just the reality of using Linux. Even ignoring that, snap and flatpak apps provide a generally awful user experience, and I fail to see how this tool would do a better job.<p>That leaves Windows and MacOS users as the primary audience for software packaged using a tool like this. It would make sense that a tool like this would prioritize MacOS&#x2F;Windows support above all else. Even the angry redditeur shown in the README clearly mentions .EXE files.<p>Why would QEMU even necessary? Docker runs fine on Windows. Maybe it&#x27;s to avoid requiring the user to install Docker? Either way, asking the user to fiddle with Hyper-V settings is bad UX.
评论 #39622358 未加载
评论 #39622416 未加载
评论 #39624849 未加载