I don’t think the issue is specifically related to pythonbugs. I don’t think the scanner is using the docker’s RAM.
I am not an expert in bitbucket, but looking at the documentation you sent, the 16GB of the size x4 is split between the docker container (15GB) and the build container (1GB).
But as the scanner is executer on the build container (as its not a docker command) the allocated RAM far exceed the available one.
I suggest you slightly lower the ran of the docker service to 13GB and allocate 2GB to the scanner engine instead of 11GB.