How to set resources for docker in Linux (Mint)

  docker, linux, linux-mint

With Docker Desktop, one can set resource usage for the docker engine.

That option is not available with Linux.
I have found resources that point to editing cgroups, but I have not been successful.

What are the steps to set, say:

4 CPUs
8GB memory
1GB swap

To all containers in the system?

Source: Docker Questions