Docker/Cypress 容器由于 M1 芯片上的 Qemu 错误而失败

jcp*_*den 11 docker cypress apple-m1

我有一个 Docker 镜像,我想在本地运行,但我相信它由于 Qemu 问题而失败,这似乎源于尝试在 M1 芯片上运行 Cypress:

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
dna          local     097c5f291db5   2 hours ago   3.66GB
Run Code Online (Sandbox Code Playgroud)

当我尝试使用本地运行图像时,docker run dna:local我得到以下信息:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
yarn run v1.22.10
$ concurrently "yarn:start:ui" "yarn:start:api" "cypress run"
[start:api] $ cd api && yarn start:dev
[start:ui] $ cd ui && yarn start
[2] [STARTED] Task without title.
[start:api] $ DEBUG=socket.io:* DISABLE_AD=1 USE_MEMORY_DB=true nodemon --inspect -r esm ./src/app.js
[2] [FAILED] Cypress failed to start.
[2] [FAILED]
[2] [FAILED] This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies
[2] [FAILED]
[2] [FAILED] Please refer to the error below for more details.
[2] [FAILED]
[2] [FAILED] ----------
[2] [FAILED]
[2] [FAILED] qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[2] [FAILED] qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[2] [FAILED]
[2] [FAILED]
[2] [FAILED] #
[2] [FAILED] # Fatal error in , line 0
[2] [FAILED] # ignored
[2] [FAILED] #
[2] [FAILED] #
[2] [FAILED] #
[2] [FAILED] #FailureMessage Object: 0x4009bb9420
[2] [FAILED] qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Run Code Online (Sandbox Code Playgroud)

我的 Dockerfile 如下所示:

FROM cypress/browsers:node14.16.0-chrome90-ff88

# Copy the project into the Docker container
COPY . /

# Install the API and UI packages
RUN yarn workspace checkin-api install
RUN yarn workspace checkin-ui install

# Run the e2e test suite
CMD yarn run e2e
Run Code Online (Sandbox Code Playgroud)

奇怪的是,如果我尝试为图像指定平台,Docker 会抱怨它无法在本地找到该图像:

docker run --platform linux/arm64/v8 dna:local
Run Code Online (Sandbox Code Playgroud)

让我得到以下信息:

Unable to find image 'dna:local' locally
docker: Error response from daemon: pull access denied for dna, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
Run Code Online (Sandbox Code Playgroud)

我假设从 Cypress Docker 存储库中提取的图像决定了所使用的架构,而不是我的 --platform 标志?如果是这样,这是否只是 Cypress 无法在我的计算机上的 Docker 容器中运行的情况?

jcp*_*den 5

看起来 Cypress 的 Docker 容器存在一个已知问题,无法与 M1 芯片正常工作:

https://github.com/cypress-io/cypress-docker-images/issues/431


Cra*_*ley 3

您可能需要使用为 M1 / Apple Silicon 构建的 Docker 版本。

https://docs.docker.com/docker-for-mac/apple-silicon/


另一件要尝试的事情是使用平台构建它,然后运行它。

docker build -t dna:local --platform linux/arm64/v8 .
Run Code Online (Sandbox Code Playgroud)