Installing Prophet (pystan build) on Docker container (buster)
Figured it out - as it was a memory issue, I just needed to allocate more memory to the Docker VM. This answer explains how to do it with the GUI. A lot of time wasted...
Well, that's what I found - I gave 6 CPUs to Docker VM, so when it tries to build a code, GCC spawns 6 threads, each of them consuming too much RAM. I can say - even 16 Gb might be not enough. So, limiting the number of CPUs for the Docker VM by the, let's say, 4 CPU might be a good choice.
For anyone else having this issue, I was building with base image python:3.7-slim
Changing to python:3.7
fixed the issue