How to check why a docker build slow?


I’m building my go program via:

RUN go install .

If I run the same command go install . on my host machine (with all cache pruned) I can see my CPU working hard (> 50% all cores). The same command run via Docker in contrast seem not use that much CPU and result is really slow build time.

Is their any way I can check resource usages for docker build command, something like docker stats?

Source: Docker Questions