I'm interested in the smallest possible Docker image that has an operating system, Rust, and Cargo and (to a certain extent) nothing else. Here's where I'm at currently (on GitHub also):
I pushed this to Docker Hub and it indicates it's 119 MB compressed (not sure what compression they do). Is there any way to reduce this further? @eddyb mentioned in IRC that there might be a way to reduce duplication between /usr/local/lib/ and /usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/, though I'm not sure how one would do this. It looks like after a fresh install, /usr/local/lib is 228.6 megabytes.
Isn't set -ex useless here? Isn't it normally used to stop a script from running as soon as there's an error and here you already have that effect since you are calling all commands with '&&'?
119MB is indeed smaller than most other images, especially Ubuntu and Debian based images which already have a 100MB-200MB base. The base Alpine container is 5MB, so I imagine moving to scratch won't result in many storage victories.
About 'gcc', I'm not sure if it's the right package. With it I have 'cannot find Scrt1.o: No such file or directory'. 'Scrt1.o' is from musl-dev and with it I get: 'undefined reference to `__rawmemchr'' but maybe cc is not using glibc.
Which create are you trying to build? Indeed, there is no gcc or g++ installed, as I was going for absolute minimal. I understand that this is not ideal for most Rust project, but at least initially when I wrote the image, I was going for a no-batteries-included image.