# Nerd Sniped by BINFMT\_MISC

DevFeed: [Nerd Sniped by BINFMT\_MISC](<https://devfeed.tech/articles/nerd-sniped-by-binfmt-misc-35180.md>)

Original publisher: [Read original article](<https://blog.jessfraz.com/post/nerd-sniped-by-binfmt_misc/>)

Published: 2018-03-04T15:25:24Z

Content type: article

Language: en

Sources: [Jessie Frazelle](<https://devfeed.tech/sources/jessie-frazelle.md>)

Topics: [Containers](<https://devfeed.tech/topics/containers.md>), [Kernel](<https://devfeed.tech/topics/kernel.md>), [Common Lisp](<https://devfeed.tech/topics/common-lisp.md>), [Lisp](<https://devfeed.tech/topics/lisp.md>), [Scripting](<https://devfeed.tech/topics/scripting.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>)

Tags: [containers](<https://devfeed.tech/tags/containers.md>), [go](<https://devfeed.tech/tags/go.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [lisp](<https://devfeed.tech/tags/lisp.md>), [scripting](<https://devfeed.tech/tags/scripting.md>)

## AI overview

The author explores using BINFMT_MISC to run scripts in different languages without installing their runtimes on the host. They combine it with binctr, a project that embeds a container image into a static executable, and demonstrate the approach with a Common Lisp container.

## Source excerpt

This is a story about how I got nerd sniped by a blog post from Cloudflare Engineering. The TLDR on their post is that you can script in Go if you use BINFMT_MISC in the kernel. BINFMT_MISC is really well documented and awesome. In the end, all they had to do to script in Go was to mount the filesystem: $ mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc Then, register the Go script binary format: $ echo ':golang:E::go::/usr/local/bin/gorun:OC' | sudo tee /proc/sys/fs/binfmt_misc/register :golang:E::go::/usr/local/bin/gorun:OC Then you can ./ any go file on your host: $ chmod u+x helloscript.go $ ./helloscript.go Hello, world! They go through all the extraordinary details of exit codes for the shell and blah blah blah. It's a great post you should really read it. Do it, go read it, then come back here and I will take it to 11. ... Okay, cool, you are back. That post was dope right? I kinda want to do this with all languages. Because I LOVE SCRIPTING. Have you seen my cloud native dotfiles? My bash scripts smell like roses. Right, so I want to do this with all languages... but what I also hate is installing shit on my host. Ew, we have containers for those silly things. Luckily, I know a thing or two about containers... A few years ago I made a project called binctr. It creates fully static, unprivileged, self-contained, containers as executable binaries. (Wow that was a lot of words, let's break it down.) What binctr does is embed an entire container image (aka rootfs) into a fully static binary and when you execute the binary it will unpack the image and run it as a container. So you get containers without a daemon or privileges and without even having the image for the rootfs of the container. You just need this one binary. (Huge thanks to @lordcyphar who got rootless containers into runc so I could actually archive my gross hack for binctr.) Kinda seems like the perfect match for trying to use all languages with BINFMT_MISC. So I tried it. (Preface: this post s