[issue36054] Way to detect CPU count inside docker container

Stéphane Wirtel report at bugs.python.org
Wed Feb 20 15:15:06 EST 2019


Stéphane Wirtel <stephane at wirtel.be> added the comment:

so, I have also tested with the last docker image of golang.

> docker run --rm --cpus 1  -it golang /bin/bash

here is the code of golang:

package main

import "fmt"
import "runtime"

func main() {
	cores := runtime.NumCPU()
	fmt.Printf("This machine has %d CPU cores.\n", cores)
}

Here is the output
> ./demo 
This machine has 4 CPU cores.

When I try with grep on /proc/cpuinfo
I get this result

> grep processor /proc/cpuinfo  -c
4


I will test with openjdk because it's related to Java and see if I can get the result of 1

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36054>
_______________________________________


More information about the Python-bugs-list mailing list