有没有办法禁止其他 docker 容器使用相同的 CPU?

Is there a way to disallow other docker containers using the same CPU?

所以很容易告诉 Docker 哪个 CPU 容器可以使用:

docker run --cpuset=7 some_container_name

但是这个命令可以运行多次并且所有这些进程共享同一个内核。有没有办法让容器独占访问 CPU 并在其他人尝试使用它时出错?

不,这不是 Docker 的功能。它需要在 Docker 以上的层(如 Kubernetes 或 ECS)上完成。但是自己实现它也相当容易。