Repository: next.js
Issue: Docker build doesn't work when you have multiple images on a single page in the app directory on Mac OS (M1).
Labels: examples

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:43:05 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6020
Binaries:
  Node: 19.8.1
  npm: 9.5.1
  Yarn: 3.5.0
  pnpm: 8.5.1
Relevant Packages:
  next: 14.0.2-canary.5
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: standalone
```


### Which example does this report relate to?

with-docker

### What browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_

### Describe the Bug

When I try to build the project, I can not build it successfully.

I got an error code.

```
 => ERROR [builder 4/4] RUN yarn build                                                                                  8.4s 
------                                                                                                                       
 > [builder 4/4] RUN yarn build:                                                                                             
1.102 yarn run v1.22.19                                                                                                      
1.207 $ next build                                                                                                           
4.392    ▲ Next.js 14.0.2-canary.5                                                                                           
4.394 
4.395    Creating an optimized production build ...
8.256 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
8.277 Segmentation fault
8.312 error Command failed with exit code 139.
8.312 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
Dockerfile:32
--------------------
  30 |     ENV NEXT_TELEMETRY_DISABLED 1
  31 |     
  32 | >>> RUN yarn build
  33 |     
  34 |     # If using npm comment out above and use below instead
--------------------
ERROR: failed to solve: process "/bin/sh -c yarn build" did not complete successfully: exit code: 139
```

### Expected Behavior

Build success on Mac OS Apple chip.

### To Reproduce

You can clone this project with the following link and have a try.
https://github.com/singleseeker/nextjs-docker-test

Here is how the errors come.

1. Use the App directory way in your project.
2. Load more than 5 images on one page.
3. Have a sharp package in your project.
4. Deploy the project with docker in Mac OS( For me, my Mac use a Apple M2 chip)

 files structure

```
├── package.json
├── public
│   ├── favicon.ico
│   └── vercel.svg
├── src
│   └── app
│       ├── layout.js
│       ├── page.js
│       └── small
```

```
// npm i sharp
import React from 'react'


import img1 from "./small/img-1.jpg";
import img2 from "./small/img-2.jpg";
import img3 from "./small/img-3.jpg";
import img4 from "./small/img-4.jpg";
import img5 from "./small/img-5.jpg";
import img6 from "./small/img-6.jpg";
import Image from 'next/image';



function Home() {
  return (
    <>
      <Image src={img1} alt="Picture of the author" />
      <Image src={img2} alt="Picture of the author" />
      <Image src={img3} alt="Picture of the author" />
      <Image src={img4} alt="Picture of the author" />
      <Image src={img5} alt="Picture of the author" />
      <Image src={img6} alt="Picture of the author" />
    </>
  )
}

export default Home
```