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

Docker build fails when targeting --platform linux/amd64, due to allocate virtual memory issue #5831

Closed
2 of 3 tasks
ryanhefner opened this issue Jul 8, 2021 · 17 comments
Closed
2 of 3 tasks

Comments

@ryanhefner
Copy link

ryanhefner commented Jul 8, 2021

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

Build should succeed, as it did in previous Docker Apple Silicon Preview versions.

Actual behavior

Build fails once it tries to execute a command, resulting in allocate virtual memory issue / core dumped, then just hangs.

 => [internal] load build definition from Dockerfile                                                                                                                         0.0s
 => => transferring dockerfile: 289B                                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                                            0.0s
 => => transferring context: 34B                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:alpine                                                                                                               0.7s
 => [stage-1 1/3] FROM docker.io/library/node:alpine@sha256:b7e2d75ecd585feed57be69cd3dee973e5c498241e64906899b3baa2169fb35a                                                 0.0s
 => [internal] load build context                                                                                                                                            0.0s
 => => transferring context: 17.88kB                                                                                                                                         0.0s
 => CACHED [stage-1 2/3] WORKDIR /app                                                                                                                                        0.0s
 => CACHED [builder 3/7] COPY ./package*.json ./                                                                                                                             0.0s
 => CACHED [builder 4/7] COPY ./yarn.lock ./                                                                                                                                 0.0s
 => [builder 5/7] RUN yarn install --frozen-lockfile --prod                                                                                                                 11.2s
 => => # #                                                                                                                                                                       
 => => # # Fatal process OOM in CodeRange setup: allocate virtual memory                                                                                                         
 => => # #                                                                                                                                                                       
 => => # qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped  

Information

  • macOS Version: 11.4
  • Intel chip or Apple chip: Apple M1
  • Docker Desktop Version: 3.5.1.7

Steps to reproduce the behavior

Dockerfile

FROM node:alpine AS builder
WORKDIR '/app'
COPY ./package*.json ./
COPY ./yarn.lock ./
RUN yarn install --frozen-lockfile --prod
COPY . .
RUN yarn build

FROM node:alpine
WORKDIR /app
COPY --from=builder /app .
EXPOSE 3000
CMD ["yarn", "start"]

Build command (ran via deploy.sh):

docker build --platform linux/amd64 -t $TAG_ENV -t $TAG_SHA -f ./services/$SERVICE/Dockerfile ./services/$SERVICE
@joninsky
Copy link

joninsky commented Jul 8, 2021

I'm having the same issue. I have tried to increase available memory for Node through this command in my docker file.

RUN set NODE_OPTIONS=--max-old-space-size=30720

However, the issue is still present.

@cmoore1776
Copy link

cmoore1776 commented Jul 17, 2021

This seems to be exclusive to node.js 16.x. Still affecting Docker Desktop 3.5.2 on Apple Silicon.

Any node or npm command (except node --version) produces this behavior.

I reproduced on debian:bullseye-slim using latest node.js (16.4.1). node.js 14 and 12 are working.

@yocoandplay
Copy link

Hello guys,

I'd like to share my experience with this issue.
I have the same problem with my Docker images and Apple M1.
For deploying to production environment on Azure, I must build my Docker images with --platform linux/amd64 option.

With DockerFile "FROM node:16-slim" base, I have the "allocate virtual memory" issue.
With DockerFile "FROM node:14-slim" base, no issue (but the build is verrrrrryyyyyy long...)

Thanks to @shamelesscookie for the observation. I'll set my DockerFiles with node 14 for the moment...

(For all : Is any solution for speedup build --platform linux/amd64 option, please ???)

Thanks for all.
Have a nice day.

@Nomad-Go
Copy link

Thank you @shamelesscookie for the observation. I changed my base image from FROM node:current-alpine3.14 to FROM node:14-alpine3.14 and it works!

@carlolucadei
Copy link

carlolucadei commented Aug 5, 2021

@Nomad-Go @shamelesscookie I'm trying to follow your hint. 🤞 for us!

EDIT: It's working for us

@petetnt
Copy link

petetnt commented Aug 11, 2021

Downgrading base image to Node 14 worked for me too. Thanks @Nomad-Go!

@abelce
Copy link

abelce commented Aug 15, 2021

@Nomad-Go it`s works

@edurodriguesdias
Copy link

edurodriguesdias commented Aug 22, 2021

Using node:14-alpine3.14 works for me! Thank you @Nomad-Go for helping 👍

@Lazzu
Copy link

Lazzu commented Aug 24, 2021

By trial-and-error I found that using node:16.3-alpine3.12 fixed this issue for me

@aaronhmiller
Copy link

Thank you @Lazzu! Seconding your find. Something broke starting with Node 16.4.

willkg added a commit to mozilla-services/tecken that referenced this issue Sep 21, 2021
This downgrades Tecken to using node 14. Tecken only uses node to build
static assets, so as long as they're building fine, it doesn't really
matter what version of node we're using.

This allows people using macs with m1 processors to build and run
Tecken. Previous to this fix, they would hit this issue:

docker/for-mac#5831
@cmoore1776
Copy link

This appears to be fixed with node 16.10.0

$ docker run --rm -it --platform=linux/amd64 --entrypoint /bin/sh node:16-alpine 
/ # node -v
v16.10.0
/ # npm -v
7.24.0

chrisamti added a commit to chrisamti/mjml-server that referenced this issue Oct 8, 2021
downgrade to node:15-alpine because of issue docker/for-mac#5831 for building on Apple M1
@aaronhmiller
Copy link

Confirming @shamelesscookie 's finding that building w/ latest version of Node (starting w/ 16.10) fixes this. Versions 16.4-16.9 have the OOM qemu issue.

@jason-magnetic-io
Copy link

@shamelesscookie finding works for me with Docker Desktop v4.1.0 (69386). It doesn't work with Docker Desktop v4.0.1
After upgrading to Docker Desktop v4.1.0, Node v16.6.0 now also works for me (it failed with Docker Desktop v4.0.1)

% docker run --rm -it --platform=linux/amd64 --entrypoint /bin/sh node:latest
# node -v
v16.6.0
# npm -v
7.19.1 

@AllanOricil
Copy link

Im facing the same problem. And changing the base image did not work for me.

@AllanOricil
Copy link

I can confirm that after upgrading docker desktop to the latest version I was able to build the image on a Mac M1

@thaJeztah
Copy link
Member

Looks like this was resolved; let me go ahead and close, but feel free to comment if you're still running into this on the latest version of Docker Desktop

@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 Dec 10, 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