Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong CPU architecture in /proc/cpuinfo when using --platform #5245

Closed
3 tasks done
wader opened this issue Jan 13, 2021 · 6 comments
Closed
3 tasks done

Wrong CPU architecture in /proc/cpuinfo when using --platform #5245

wader opened this issue Jan 13, 2021 · 6 comments

Comments

@wader
Copy link

wader commented Jan 13, 2021

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: D3CC2969-09ED-4A43-A421-17E82049B52F/20210113151536

Expected behavior

That /proc/cpuinfo indicated the emulated CPU.

Actual behavior

/proc/cpuinfo shows intel CPU.

### Information

macOS version: 10.15.7

Docker for Mac: 3.0.4

$ docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.4
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:12:42 2020
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:15:23 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Steps to reproduce the behavior

$ docker run --rm -ti --platform linux/arm64 alpine:3.12
/ # uname -a
Linux 25e3218c592e 4.19.121-linuxkit #1 SMP Tue Dec 1 17:50:32 UTC 2020 aarch64 Linux
/ # cat /proc/cpuinfo | grep model
model		: 142
model name	: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
model		: 142
model name	: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
model		: 142
model name	: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
model		: 142
model name	: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
/ #

I first reported the issue here containerd/containerd#4109 but then got unsure it's the correct place.

@wader
Copy link
Author

wader commented Jan 14, 2021

I noticed this issue while trying to build various software packages locally using docker mac and in github action using qemu. Mainly the problem happens with configure script, cmake script etc that read /proc/cpuinfo and builds that ends up using gcc -mcpu=native etc which seems to auto detect cpu using cpuinfo (https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/config/arm/driver-arm.c). -mcpu=native seems to fallback to a default arm config and that can sometimes cause errors like Error: selected processor does not support usad8 ip,r4,r5' in ARM mode`

@StefanScherer
Copy link
Member

Thanks for reporting, but this is not a bug. This also happens on Linux hosts with Intel CPU:

$ docker run --rm --privileged hypriot/qemu-register
$ docker run --rm -ti --platform linux/arm64 alpine:3.12
/ # uname -a
Linux 64ccc03e91e3 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 aarch64 Linux
/ # cat /proc/cpuinfo | grep model
model		: 158
model name	: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz

This is becaus it still runs with the Linux kernel on Intel, only with QEMU to emulate the arm64 binaries. And therefore it still shows the cpuinfo from the host. Container are more or less only namespaces and no full encapsulated emulators across different CPU architectures.

Running containers with a different architecture might run into issues when the application checks for such information and then mis-interprets that it's running eg. ARM binaries. But that's part of the business logic in the application and we can't do anything about this.

I'll close this ticket, but feel free to comment if you have questions.

@wader
Copy link
Author

wader commented Jan 15, 2021

@StefanScherer Ok! thanks for the answer. Would it be possible for docker to somehow have synthetic proc files to workaround this?

@StefanScherer
Copy link
Member

@wader No, we're not keen on messing around with these proc files. :-)

@wader
Copy link
Author

wader commented Jan 15, 2021

@StefanScherer true :) i was thinking just cpuinfo and maybe some others that are known to be ”wrong”? maybe its not easy to overlay just some files in proc also?

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants