13 ms·
docker2exe: Convert a Docker image to an executable
- Epskampie 1y ago> Requirements on the executing device: Docker is required.
- alumic 1y agoI was so blown away by the title and equally disappointed to discover this line. Pack it in, guys. No magic today.
- stingraycharles 1y agoThank god there’s still this project that can build single executables that work on multiple OS’es, I’m still amazed by that level of magic.
- cozyman 1y ago[flagged]
- harha_ 1y agoYeah, it feels like nothing but a little trick. Why would anyone want to actually use this? The exe simply calls docker, it can embed an image into the exe but even then it first calls docker to load the embedded image.
- jve 1y agoI see a use case. The other day I wished that I could pack CLI commands as docker containers and execute them as CLI commands and get return codes. I haven't tried this stuff, but maybe this is something in that direction.
- matsemann 1y agoI do that for a lot of stuff. Got a bit annoyed with internal tools that was so difficult to set up (needed this exact version of global python, expected this and that to be in the path, constantly needed to be updated and then stuff broke again). So I built a docker image instead where everything is managed, and when I need to update or change stuff I can do it from a clean slate without affecting anything else on my computer. To use it, it's basically just scripts loaded into my shell. So if I do "toolname command args" it will spin up the container, mount the current folder and some config folders some tools expect, forward some ports, then pass the command and args to the container which runs them. 99% of the time it works smooth. The annoying part is if some tool depends on some other tool on the host machine. Like for instance it wants to do some git stuff. I will then have to have git installed and my keys copied in as well for instance.
- rzzzt 1y agoCoreOS had a toolbox container that worked similarly to the one you have (the Podman people took over its maintenance): https://github.com/containers/toolbox https://github.com/containers/toolbox
- endofreach 1y ago> my keys copied in as well for instance. Tip: you could also forward your ssh agent. I remember it was a bit of a pain in the ass on macos and a windows WSL2 setup, but likely worth it for your setup.
- lelanthran 1y ago> I see a use case. The other day I wished that I could pack CLI commands as docker containers and execute them as CLI commands and get return codes I don't understand this requirement/specification; presumably this use-case will not be satisfied by a shell script, but I don't see how. What are you wanting from this use-case that can't be done with a shell script?
- lazide 1y agoPresumably, they don’t want to write/maintain a shell script wrapper for every time they want to do this, when they could use a tool which does it for them.
- johncs 1y agoBasically the same as Python’s zipapps which have some niche use cases. Before zipapp came out I built superzippy to do it. Needed to distribute some python tooling to users in a university where everyone was running Linux in lab computers. Worked perfectly for it.
- j45 1y agoCould be ease of use for end users who don't docker.
- worldsayshi 1y agoBut now you have two problems.
- throwanem 1y agoThe first of which can be p90 solved by "Okay, type 'apt install dash capital why docker return,' tell me what happens...okay, and 'docker dash vee' says...great! Now..." Probably takes a couple minutes, maybe less if you've got a good fast distro mirror nearby. More if you're trying to explain it to a biologist - love those folks, they do great work, incredible parties, not always at home in the digital domain.
- Hamuko 1y agoI feel like it's much easier to send a docker run snippet than an executable binary to my Docker-using friends. I usually try to include an example `docker run` and/or Docker Compose snippet in my projects too.
- deleted 1y ago[deleted]
- drawfloat 1y agoIs there any alternative way of achieving a similar goal (shipping a container to non technical customers that they can run as if it were an application)?
- regularfry 1y agoIt feels like there ought to be a way to wrap a UML kernel build with a container image. Never seen it done, but I can't think of an obvious reason why it wouldn't work.
- mrbluecoat 1y agoSee the dockerc comment above
- arjvik 1y agoGood friend built dockerc[1] which doesn't have this limitation! [1]: https://github.com/NilsIrl/dockerc https://github.com/NilsIrl/dockerc
- hnuser123456 1y agoThat screenshot in the readme is hilarious. Nice project.
- dheera 1y agoBut will this run inside another docker container? I normally hate things shipped as containers because I often want to use it inside a docker container and docker-in-docker just seems like a messy waste of resources.
- rcfox 1y agoDoesn't podman get around a lot of those issues?
- dheera 1y agoAw hell, more band-aids because people don't want to get software distribution done right. Can we please go back to the days of sudo dpkg -i foo.deb and then just /usr/bin/foo ?
- johnisgood 1y agoI am still using "ar x" and "tar xvf" for .deb files on Void Linux, because some projects only release .deb files!
- vinceguidry 1y agoDocker in Docker is not a waste of resources, they just make the same container runtime the container is running on available to it. Really a better solution than a control plane like Kubernetes.
- cik 1y agoIt sounds like docker export and makeself combined. We already ship to select customers prebuilt containers exactly this way.
- revskill 1y agoSo baiscally i could bundle the linux os as an exe and run in windows.
- arjav0703 1y agoThis is useful if you want to share your container (probably something that is prod ready) to someone who knows nothing about docker. An usecase would be, you built a custom software for someone's business/usecase and they are the only one using that particular container.
- dennydai 1y agoJust use shebang https://news.ycombinator.com/item?id=38987109 https://news.ycombinator.com/item?id=38987109 #!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
- cess11 1y agoThat's bat guano insane, but I still like it more than TFA.
- renewiltord 1y agoIt's not that crazy. Another fun use is with a `uv run` shebang https://news.ycombinator.com/item?id=42855258 https://news.ycombinator.com/item?id=42855258
- tomjakubowski 1y agoNote to others who might like to write long shebangs: the -S argument there to /usr/bin/env is load-bearing, and if you forget it weird stuff will happen, at least on most Linux systems. I wrote about it a few years ago, based on a true story. https://crystae.net/posts/two-shebang-papercuts/ https://crystae.net/posts/two-shebang-papercuts/
- kkapelon 1y agoThis is just a simpler wrapper over the docker executable that you need to have installed anyway.
- aussieguy1234 1y agoOn Linux, there would be little to no performance penalty to something like this since Docker is just fancy chroot, re using the same kernel as the host. But not on other platforms. They are the same but run Linux in a VM.
- sunrunner 1y agoI'm just as disappointed as I was when I first heard about being able to create 'Self-contained Executable Programs with Deno Compile', perhaps slightly more even as at least that bundled the interpreter. In all seriousness, Docker as a requirement for end-users to create an executable seems like a 'shift-right' approach to deployment effort, as in, instead of doing the work to make a usable standalone executable, a bunch of requirements for users are just pushed on to them. In some cases your users might be technical, but even then Docker only seems to makes sense when its kept inside an environment where the assumption of a container runtime is there. I assume extra steps are needed to allow the 'executable' to access filesystem resources, making it sandboxed but not in a way that's helpful for end users?
- 7bit 1y agoDocker as a requirement for end-users is terrible no matter what.
- wojtek1942 1y agoWhy the disappointment with Deno compile? I have not used it but from the website it seems that the end user does not need Deno to be installed. What is the shortcoming you are referring to?
- sunrunner 1y agoIt's not a fair comparison on my part but before reading through the docs some of the initial wording around Deno compile seemed to imply (or I inferred) that a platform native executable would be produced from the process. Wishful thinking on my part I guess. Other languages like Golang making it relatively easy to build _native_ programs and to cross-compile them makes it a solid choice CLI tools, and I was genuinely hoping that more tooling like that was coming to other ecosystems. Perhaps naive to expect a shift like that for a language that's always been interpreted, but I like when I can run developer tools as native programs instead of ending up with various versions of a runtime installed (npx doesn't _solve_ this problem, merely works around it).
- rullopat 1y agoIt's great for sending your 6 GB hello world exe to your friends I suppose
- xandrius 1y agoThe beauty of docker is that it is a reflection of how much someone cares about deployments: do you care about being efficient? You can use `scratch` or `X-alpine`. Do you simply not care and just want things to work? Always go for `ubuntu` and you're good to go! You can have a full and extensive api backend in golang, having a total image size of 5-6MB.
- hereonout2 1y agoI've done both, tiny scratch based images with a single go binary to full fat ubuntu based things. What is killing me at the moment is deploying Docker based AI applications. The CUDA base images come in at several GB to start with, then typically a whole host of python dependencies will be added with things like pytorch adding almost a GB of binaries. Typically the application code is tiny as it's usually just python, but then you have the ML model itself. These can be many GB too, so you need to decide whether to add it to the image or mount it as a volume, regardless it needs to make it's way onto the deployment target. I'm currently delivering double digit GB docker images to different parts of my organisation which raises eyebrows. I'm not sure a way around it though, it's less a docker problem and more an AI / CUDA issue. Docker fits current workflows but I can't help feeling having custom VM images for this type of thing would be more efficient.
- kevmo314 1y agoPyTorch essentially landed on the same bundling CUDA solution, so you're at least in good company.
- hereonout2 1y agoYep, then I have some projects that have pytorch dependencies which use it's own bundled CUDA and non-pytorch dependencies that use a CUDA in the usual system wide include path. So CUDA gets packaged up in the container twice unless I start building everything from source or messing about with RPATHs!
- Alex_001 1y agoThis is super cool — especially for sharing tools with non-technical users or bundling CLIs without asking people to install Docker. Packaging infra-heavy apps into a simple .exe could really smooth out distribution. Curious how it handles startup time and embedded filesystem size.
- shric 1y ago> or bundling CLIs without asking people to install Docker. Except it requires people to install Docker.
- draneone 1y ago[dead]
- hda111 1y agoWhy? Would be easier to embed both podman and the image in one executable to create a self-contained file. No docker needed.
- PicassoCTs 1y agoSo, does this work with a dockerswarm? As in a whole services swarm- get converted down into a monolith?
- isaacimagine 1y agoSee also: dockerc https://github.com/NilsIrl/dockerc https://github.com/NilsIrl/dockerc
- ransom1538 1y agoAh finally. We have finished where we started.
- blueflow 1y agoThat was my first thought. Back in the days you gave your friends a stand-alone *.COM program on a floppy. We have come full circle on static linking.
- rietta 1y agoI remember thinking that the Visual Basic runtime was unacceptable bloat overhead and now this. Cool work though. Also reminds me of self extracting WinZip files.
- sitkack 1y agoAt some point in the future we will be nostalgic for the monstrosities of the present.
- int_19h 1y ago"ChatGPT, execute this natural language description of what the program should do"
- int_19h 1y agoI remember those times, as well. There was an amusing (in retrospect) period in late 90s - early 00s where one of the metrics for RAD tools of the day was how large a hello world type app is. Delphi was so popular then in part because it did very well on that metric - the baseline was on the order of 300 Kb, if I remember correctly, and you could have fairly complicated apps under 1 Mb. Visual Basic was decidedly meh on that count because between your EXE and MSVBVM60.DLL, it wouldn't fit on a single 1.44 Mb floppy.
- fifilura 1y agoDocker is mostly backend, but I wonder how far we are from universally executable native applications? I.e. download this linux/mac/windows application to your windows/linux/mac computer. Double-click to run. Seems like all bits and pieces are already there, just need to put them together.
- ivewonyoung 1y agoHow different would that be from Flatpak
- fifilura 1y agoDoes it make linux applications run on Windows or mac?
- woodrowbarlow 1y agohttps://justine.lol/ape.html https://justine.lol/ape.html -- αcτµαlly pδrταblε εxεcµταblε this works for actual compiled code. no vm, no runtime, no interpreter, no container. native compiled machine code. just download and double-click, no matter which OS you use.
- Piskvorrr 1y ago"Please note this is intended for people who don't care about desktop GUIs, and just want stdio and sockets without devops toil."
- woodrowbarlow 1y agocosmopolitan-libc has aspirations (but not concrete plans) to add SDL interfaces for all supported platforms. this would allow APE executables to compile-in cross-platform UI toolkits like QT.
- Piskvorrr 1y agoAspirations are nice and all. Java's had them for three decades now.
- nine_k 1y agoTired: docker run. Wired: docker2exe. Inspired: AppImage. (I'll show myself out.)