Limiting a Docker Container to a single cpu core

前端 未结 2 777
故里飘歌
故里飘歌 2021-02-01 18:02

I\'m trying to build a system which runs pieces of code in consistent conditions, and one way I imagine this being possible is to run the various programs in docker containers w

相关标签:
2条回答
  • 2021-02-01 18:41

    I've tried to provide a tutorial on container resource alloc.

    https://gist.github.com/afolarin/15d12a476e40c173bf5f

    0 讨论(0)
  • 2021-02-01 18:54

    If you use a newer version of Docker, you can use --cpuset-cpus="" in docker run to specify the CPU cores you want to allocate:

    docker run --cpuset-cpus="0" [...]
    

    If you use an older version of Docker (< 0.9), which uses LXC as the default execution environment, you can use --lxc-conf to configure the allocated CPU cores:

    docker run --lxc-conf="lxc.cgroup.cpuset.cpus = 0" [...]
    

    In both of those cases, only the first CPU core will be available to the docker container. Both of these options are documented in the docker help.

    0 讨论(0)
提交回复
热议问题