On Mac, the Docker daemon runs on a minimal Linux distro, that in turn runs on top of a hyperKit VM. Here you obviously have control over how much memory the VM gets.
On Ubuntu, docker runs directly on the host, so it has all memory available that the host has.
That being said, you can obviously decide how much memory the container gets.
docker run -it --cpus=".5" imagename is how you would achieve this.