PAM limits apply only to processes that play well with PAM. By default, when you run a shell in a container, it will have nothing to do with PAM, and setting limits through PAM will simply not work.
Here are some other ways to do it!
Instead of starting the process immediately, you can run a tiny shell script that will make the appropriate ulimit calls before executing your process.
If you want an interactive shell, you can run login -f <username> (for example, login -f root ); which will use the normal login process to automatically register you with the machine (and this should go through the usual PAM mechanisms).
If you want all containers to be subject to these restrictions, you can set limits on your system and then restart Docker with those lower limits; containers are created by Docker, and by default they also inherit these limits.
source share