Count number of allowed CPUs in a Docker container

You can use the nproc shell script tool.

So it would be -j$(nproc) in the make command line in question.