Limit resources without swarm

How can I limit cpu, memory or any other resources for a container without a swarm?

By using the right version of the docker compose specs!
Version 2 is aimed for use with docker-compose and supports ALL configuration items you can use with docker run.
Version 3 is aimed for use with docker swarm and adds configuration items required for swarm deployments, while renaming and moving other configuration items AND removing their counterparts for docker-compose deployments. For compatibility reasons docker-compose can deploy v3.x compose files, but it will ignore the swarm specifc configuration items.

Use latest v2 and check whatever the specs provide. I am sure there is a mem_limit, but unsure about a cpu limit. Example value for mem_limit: 1024M or 1G.

I found it, here is a working example:
version: ‘2.4’
services:
my-nginx:
image: nginx:latest
ports:
- “80:80”
mem_limit: 300m

More about the topic an be found here: https://docs.docker.com/compose/compose-file/compose-file-v2/