Docker image for Erlang VM with minimal memory/disk usage

Hi guys,

Is there any Docker image I can use to build the smallest Erlang VM in term of memory usage and disk space?

Currently, I’m shipping my containers based on Ubuntu 22.04 LTS. They are pretty large and consume +200MB of RAM during startup (not even under load).

My task in the next weeks is to deploy more containers, and I can’t afford wasting memory like that.

Disclaimer: newbie here. I know only basics Docker.

Many thanks

If I just start an Erlang shell it uses about 37 MB of memory (as shown by erlang:memory(total)) and then another 13 MB in caches and pre-allocated memory (docker stats shows 50 MB of memory usage). To get that value down a bit I can start erl like this:

docker run -it erlang:26 erl +S 1 +SDio 1 +P 1024 +Q 1024 -mode minimal

That brings the memory usage down to 11 MB with 9 MB in caches etc, but it puts some constraints on the system that you might not want.

To decrease the amount of diskspace used, you should go for a multistage docker build where you only copy over your release. Like what is done here: GitHub - erlang/docker-erlang-example: HowTo Erlang in Docker and specifically in this Dockerfile.

2 Likes

@garazdawi thanks a lot. Let me give it go

Jade Allen talks about it in this presentation Code as infrastructure in the BEAM ecosystem - Jade Allen | Code BEAM Europe 2023 :slight_smile:

1 Like