Linux containers contain no Linux, aka the actual Linux (i.e. the kernel) resides outside the container. What is needed inside the container is only what the program needs for interfacing to stuff, e.g. libraries and a network resolver. The need for libraries goes away with a static link, with musl or maybe relibc.
Is it possible to have a container image with only a Rust executable inside? What classes of problems can't be solved this way, and require at least parts of Linux userland? Is there work underway to reduce this, by replacing those things with pure Rust?
I have no idea why people use containers. I gather that half the motivation is to be able to wrap up all the dependencies of a project so that they are not subject to the whims and changes of whatever platform they run on.
I also get the idea that use of containers is motivated by the desire for isolation from the rest of the system. Limiting access to memory, files, network, peripherals etc. Basically security concerns. Whilst avoiding the overheads of a full blown virtual machine.
If you need the latter then a statically built Rust application does not get you there.
The other motivation is to avoid installing all of the dependencies to the local system. That much is about managing conflicting requirements. Just ask sysadmins why you should never sudo pip install and you'll get the whole gamut of rationale for not polluting the global namespace.
Containers isolate the application from the rest of the system not so much for security (it's kind of a nice side-effect, when it works) but because conflict management is a nightmare at scale. [1]
For OP: I agree that MUSL gets you a long way to the "single binary" deployment that you are looking for. One of the challenges I faced numerous times when attempting this is that too often one of my transient dependencies needs OpenSSL and it's a real slog to deal with. Sometimes you can configure feature flags on all of your dependencies to use rustls.
You’re right that containers are not needed if they don’t contain any dependencies. OTOH in a world where you’re expected to provide your app for provisioning via Kubernetes or Openshift, that point becomes moot.