Docker isn’t running multiple layers of Ubuntu. It is a container with Ubuntu software installed, but you are still running on the host OS. RAM wise, it is using the same amount as if you installed everything separately (maybe slight variations but not substantial). The main impact of Docker is the disk space usage because it uses a copy on write file system. Meaning every change to the file system appends the data somewhere new on the disk vs overwriting the existing content. This is mitigated by flattening and other means.
Needless to say, using Docker is a boon overall for Discourse and the tech community as a whole. You should really read up on it more, it is quite cool and much better than VMs for everything.