Alternative to limit process in a container to specific cores?

To limit a process under linux to certain cores, i have always used taskset.
e.g. taskset -c 1 /usr/bin/convert
Unfortunately, this seems not to work in a container. Has anyone an idea or work around to do the same inside a container?

You may be able to create a sub-cgroup and use the cpuset controller to achieve this.

If using systemd as init system, it’s also something that’s made available through unit configuration.

Thanks @stgraber,
first I head to learn a bit more about cgroups. My aim is to limit load from tools like imagemagick.
I now create a subgroup as

sudo cgcreate -a $USER -t $USER -g cpu:limitapp

then depending on available cores from cat /sys/fs/cgroup/cpuset.cpu I set

echo 7 > cpuset.cpus

and then start

cgexec -g cpuset:limitapp convert

its not as simple like limits.cpu=1 but at least I know found a way.

Thank you!