Default per-container memory limit

I would like to have a default memory limit for each Docker container.

I know I can use --memory when running a container. Yet the problem is the host is shared by many developers and I can’t expect everybody to remember to do it.

I want the containers run without an explicit --memory parameter to be limited to e.g. 4GB instead of being able to see the whole hosts memory.

I tried to setup CGroup limits as described in The problem is that it’s a limit on total memory used by all containers.

Can I setup a per-container memory limit?

Source: StackOverflow