next.js: NextJS v13.4.16 does not work in docker container

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: #1 SMP PREEMPT_DYNAMIC Fri, 11 Aug 2023 11:03:36 +0000
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.16
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: standalone

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/vercel/next.js/blob/canary/examples/with-docker/README.md

To Reproduce

Describe the Bug

Docker container with Next app starts but do not serve any content

Expected Behavior

Docker container should start and serve application

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Google Clound

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 4
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@michalvadak I verified the application runs correctly when removing the HOSTNAME env var: CleanShot 2023-08-16 at 12 19 52@2x

The reason this was set explicitly before is that there was a bug with IPv6 handling, if the hostname docker assigns was IPv6 instead of IPv4 Next.js wouldn’t function correctly, that was fixed in the latest stable release thanks to @DuCanhGH, so now the HOSTNAME env var is no longer required by default 👍

Can you try changing ENV HOSTNAME localhost to ENV HOSTNAME 0.0.0.0, or ENV HOSTNAME ::? Next now listens on localhost, rather than 0.0.0.0, when HOSTNAME is set to localhost 😃 Perhaps the Dockerfile should be updated.

@nguaman sounds like Google Cloud Run doesn’t provide HOSTNAME, perhaps a note with a commented out ENV HOSTNAME 0.0.0.0 should be added 😃

Hello, Just FYI.

If I remove ‘ENV HOSTNAME 0.0.0.0’, it doesn’t work on Google Cloud Run.