question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[with-docker] COPY failed: stat app/.next/standalone: file does not exist

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #18~20.04.1-Ubuntu SMP Sun Jul 3 08:20:07 UTC 2022
Binaries:
  Node: 16.16.0
  npm: 8.11.0
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.0.10
  react: 17.0.2
  react-dom: 17.0.2

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

I am running sudo docker build -t myapp . (on a GCP VM) and I get this error below:

Step 21/26 : COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY failed: stat app/.next/standalone: file does not exist

Note: I’ve done all required step for existing projects as described here.

Expected Behavior

Build the image without error

To Reproduce

  • Copy Dockerfile in the base directory of your app
  • Update next.config.js like so:
// next.config.js
module.exports = {
  // ... rest of the configuration.
  output: 'standalone',
}
  • Run sudo docker build -t myapp .

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
balazsorban44commented, Jul 15, 2022

This is because you are on an older version of Next.js (12.0.10) that did not use output: "standalone" but experimental: {outputStandalone: true}. You should upgrade next@latest and it should work. (Note that experimental features are not covered by semver. Relevant PR #37994)

0reactions
github-actions[bot]commented, Aug 20, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't create a docker image for COPY failed: stat /var/lib ...
I had another case wherein I was using a directory from the parent directory and docker can only access files present below the...
Read more >
COPY failed: stat /var/lib/docker/tmp/docker ... - GitHub
Description I have a Dockerfile that has the line: COPY MyAgSourceAPI/conf/php/testsql.php /var/www/ But it causes the error: COPY failed: ...
Read more >
Docker COPY failed: stat no source files were specified - Jhooq
6 Ways to fix – Docker COPY failed: stat no source files were specified · Source path is incorrect · Incorrect file ·...
Read more >
stat /var/lib/docker/tmp/docker-xxx : no such file or directory
The target/demo-0.0.1-SNAPSHOT.jar file I am trying to copy is present in my github repository. Not sure what could be happening with the ...
Read more >
COPY failed stat var lib docker tmp docker-builder root page ...
To copy files from the base system to the docker container, you have to make sure that all the files are present where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found