How to check if enough resources are present before spawning docker contaner

Hello everyone, i have a python program which gives me the option of running any of the docker images installed on my computer.I have a question is that before that python program spawns the next container,is there any where i can know that enough resources are present are present before starting it.