top of page
GeekGuy

Docker on Apple Silicon M1 - updated in September 2021


It has been 8 months since the first time Apple Silicon M1 released, an ARM SoC develeped by Apple on ARM architecture. There are a lot of arguement between x86 and arm64 performance, compatibility, capability and so on.


But now, July 2021, is there any concerns from your side for Apple Silicon M1. Please check in this article.


Compatibility

I have used Macbook Air M1 with very basic system configuration: 8GB memory, 256GB disk.


The very first time, I recognize many apps did not support Apple M1 natively. But until now, it gradually disappear.


As you can see, I opened 303 processes, but there are 24 processes is running on Rosetta (a compiler to run x86 on ARM). It seems to 7.9% of processes is not compatible with Apple M1.


How about Docker?


Yeah, of course, Docker officially support Apple M1 natively according to Docker site. But why are there some Intel process alongside with Apple in Kind column. I have inspected it and have an answer is the UI (Docker client) still running on Intel x86, but the Docker Engine is running on Apple Silicon, sound good!




Performance


Now we test the performance, I have a Dockerfile here. And I will test build on ARM & Linux/AMD64 architecture platform.




FROM node:14.15.4-alpine3.12
ENV PATH /app/node_modules/.bin:$PATH

# workdir
WORKDIR /app

# ENV
ENV PORT 1337
ENV HOST 0.0.0.0

COPY . ./
RUN yarn install
RUN yarn build

# start
EXPOSE 1337
CMD yarn develop

Build Docker image on ARM with flag --platform linux/arm64 appears error:


$ docker build -t test --platform linux/arm64
[+] Building 91.0s (9/10)
 => [internal] load build definition from Dockerfile                                                                     0.0s
 => => transferring dockerfile: 491B                                                                                     0.0s
 => [internal] load .dockerignore                                                                                        0.0s
 => => transferring context: 2B                                                                                          0.0s
 => [internal] load metadata for docker.io/library/node:14.15.4-alpine3.12                                               5.8s
 => [auth] library/node:pull token for registry-1.docker.io                                                              0.0s
 => [1/5] FROM docker.io/library/node:14.15.4-
 => [internal] load build context                                                                                        0.3s
 => => transferring context: 1.70MB                                                                                      0.1s
 => [2/5] WORKDIR /app                                                                                                   0.2s
 => [3/5] COPY . ./                                                                                                      0.0s
 => ERROR [4/5] RUN yarn install                                                                                        73.3s
------
 > [4/5] RUN yarn install:
#9 0.247 yarn install v1.22.5
#9 0.298 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
#9 0.301 [1/5] Validating package.json...
#9 0.303 [2/5] Resolving packages...
#9 11.24 [3/5] Fetching packages...
#9 28.47 warning url-loader@1.1.2: Invalid bin field for "url-loader".
#9 52.94 info fsevents@2.1.3: The platform "linux" is incompatible with this module.
#9 52.94 info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 52.95 info fsevents@2.3.1: The platform "linux" is incompatible with this module.
#9 52.95 info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 52.95 info fsevents@1.2.13: The platform "linux" is incompatible with this module.
#9 52.95 info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
#9 52.95 [4/5] Linking dependencies...
#9 52.95 warning " > @material-ui/core@4.11.3" has unmet peer dependency "react@^16.8.0 || ^17.0.0".
#9 52.95 warning " > @material-ui/core@4.11.3" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/styles@4.11.3" has unmet peer dependency "react@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/styles@4.11.3" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/system@4.11.3" has unmet peer dependency "react@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/system@4.11.3" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/utils@4.11.2" has unmet peer dependency "react@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > @material-ui/utils@4.11.2" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0".
#9 52.95 warning "@material-ui/core > react-transition-group@4.4.1" has unmet peer dependency "react@>=16.6.0".
#9 52.95 warning "@material-ui/core > react-transition-group@4.4.1" has unmet peer dependency "react-dom@>=16.6.0".
#9 52.95 warning " > react-file-input@0.2.5" has unmet peer dependency "react@0.x".
#9 52.95 warning "strapi-admin > bootstrap@4.5.3" has unmet peer dependency "jquery@1.9.1 - 3".
#9 52.96 warning "strapi-admin > bootstrap@4.5.3" has unmet peer dependency "popper.js@^1.16.1".
#9 52.96 warning "strapi-plugin-users-permissions > grant-koa@5.4.8" has unmet peer dependency "koa@>=2.0.0".
#9 69.75 [5/5] Building fresh packages...
#9 72.58 error /app/node_modules/sharp: Command failed.
#9 72.58 Exit code: 1
#9 72.58 Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
#9 72.58 Arguments:
#9 72.58 Directory: /app/node_modules/sharp
#9 72.58 Output:
#9 72.58 info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linuxmusl-arm64v8.tar.br
#9 72.58 ERR! sharp Prebuilt libvips 8.10.0 binaries are not yet available for linuxmusl-arm64v8
#9 72.58 info sharp Attempting to build from source via node-gyp but this may fail due to the above error
#9 72.58 info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
#9 72.58 gyp info it worked if it ends with ok
#9 72.58 gyp info using node-gyp@5.1.0
#9 72.58 gyp info using node@14.15.4 | linux | arm64
#9 72.58 gyp ERR! find Python
#9 72.58 gyp ERR! find Python Python is not set from command line or npm configuration
#9 72.58 gyp ERR! find Python Python is not set from environment variable PYTHON
#9 72.58 gyp ERR! find Python checking if "python" can be used
#9 72.58 gyp ERR! find Python - "python" is not in PATH or produced an error
#9 72.58 gyp ERR! find Python checking if "python2" can be used
#9 72.58 gyp ERR! find Python - "python2" is not in PATH or produced an error
#9 72.58 gyp ERR! find Python checking if "python3" can be used
#9 72.58 gyp ERR! find Python - "python3" is not in PATH or produced an error
#9 72.58 gyp ERR! find Python
#9 72.58 gyp ERR! find Python **********************************************************
#9 72.58 gyp ERR! find Python You need to install the latest version of Python.
#9 72.58 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#9 72.58 gyp ERR! find Python you can try one of the following options:
#9 72.58 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#9 72.58 gyp ERR! find Python   (accepted by both node-gyp and npm)
#9 72.58 gyp ERR! find Python - Set the environment variable PYTHON
#9 72.58 gyp ERR! find Python - Set the npm configuration variable python:
#9 72.58 gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#9 72.58 gyp ERR! find Python For more information consult the documentation at:
#9 72.58 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#9 72.58 gyp ERR! find Python **********************************************************
#9 72.58 gyp ERR! find Python
#9 72.58 gyp ERR! configure error
#9 72.58 gyp ERR! stack Error: Could not find any Python installation to use
#9 72.58 gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
#9 72.58 gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
#9 72.58 gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
#9 72.58 gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
#9 72.58 gyp ERR! stack     at exithandler (child_process.js:315:5)
#9 72.58 gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:327:5)
#9 72.58 gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
#9 72.58 gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
#9 72.58 gyp ERR! stack     at onErrorNT (internal/child_process.js:465:16)
#9 72.58 gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
#9 72.58 gyp ERR! System Linux 5.10.25-linuxkit
#9 72.58 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#9 72.58 gyp ERR! cwd /app/node_modules/sharp
#9 72.58 gyp ERR! node -v v14.15.4
#9 72.58 gyp ERR! node-gyp -v v5.1.0
#9 72.58 gyp ERR! not ok
#9 72.58 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn install]: exit code: 1

The error related to CPU architecture, because my packages are not specified for multiple arch.


During build, you can see the chart of CPU usage as below


The average of CPU Usage is 50% approximately, but the temperature is not too hot.


With Linux/AMD64, it could finish without any problems.


$ docker build -t test --platform linux/amd64 .
[+] Building 491.1s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                     0.0s
 => => transferring dockerfile: 37B                                                                                      0.0s
 => [internal] load .dockerignore                                                                                        0.0s
 => => transferring context: 2B                                                                                          0.0s
 => [internal] load metadata for docker.io/library/node:14.15.4-alpine3.12                                               3.1s
 => [internal] load build context                                                                                        0.1s
 => => transferring context: 16.80kB                                                                                     0.0s
 => [1/5] FROM docker.io/library/node:14.15.4-alpine3.12@sha256:55bf28ea11b18fd914e1242835ea3299ec76f5a034e8c6e42b2ede7  8.3s
 => => resolve docker.io/library/node:14.15.4-
 => [2/5] WORKDIR /app                                                                                                   0.2s
 => [3/5] COPY . ./                                                                                                      0.0s
 => [4/5] RUN yarn install                                                                                             208.1s
 => [5/5] RUN yarn build                                                                                               241.9s
 => exporting to image                                                                                                  29.3s
 => => exporting layers                                                                                                 29.3s
 => => writing image sha256:4a87c529b22c4a6ae6621216faf5a9a6d5e528d809da6f413771191652a11047                             0.0s
 => => naming to docker.io/library/test:latest                                                                             0.0s

Conclusion


There is no 100% applications & tools supporting natively Apple Silicion M1.


Until now, I have some comments about this beast:

  • Pros:

    • Very cool when running office softwares.

    • High performance but sometime not stable.

    • Support quickly most common tools.

  • Cons:

    • The temperature is high when compile C/C++.

    • Not support 2 external monitor.

    • Some apps still keep crashing accidentially, but not much.


108 views0 comments

コメント

5つ星のうち0と評価されています。
まだ評価がありません

評価を追加
Stationary photo

Be the first to know

Subscribe to our newsletter to receive news and updates.

Thanks for submitting!

Follow us
bottom of page