Those tools aren't optimized for running arbitrary binaries - hence containers.
It feels so good to skip over all the Docker tools, config and services to build a Go app.
I wrote up more details here:
https://github.com/nzoschke/gofaas/blob/master/docs/dev-pack...
I wrote up some documentation about this for my use case just in case I ever have to go back and change it.
You can see it here: https://fn.lc/post/docker-scratch/
Please don't run untrusted code in Docker, it's not designed for security.
https://security.stackexchange.com/questions/107850/docker-a...
I run with the flags: --net=none --cap-drop=all --cpus=1 --read-only --tmpfs=/tmp:rw,size=1g,mode=1777,noexec
This gives it no way to communicate with the outside world and drops all capabilities so it's not allowed to interact with the kernel at all. Setting CPU limit to be 1 also prevents DOS attacks internally.
I also run the process under the nobody user which entirely avoids the "container root is system root" issue.
I'm also only sort of running "untrusted" code. I'm running tensorflow models which can do arbitrary computation but are more secure than just running raw code.
Also, port and volume mapping, so the container/go binary does not need to know physical/host pathnames to data files.