Fork bomb stalls other Docker containers

I figured that I could set a limit on user processes in /etc/security/limits.conf permanently, but this doesn’t seem to apply if I can’t restart the OS. Is there a way to set user processes limits from a Dockerfile?