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
- Follow the instructions here: https://github.com/vercel/next.js/blob/canary/examples/with-docker/README.md
- be sure you have Next v13.4.16
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
- Update Docker example to remove HOSTNAME (#54102) With the latest changes in stable Next.js setting HOSTNAME is not longer required for the image to function correctly 👍 Fixes #54093 — committed to vercel/next.js by timneutkens 10 months ago
- Update Dockerfile with new Nextjs requirement https://github.com/vercel/next.js/issues/54093 — committed to carrismetropolitana/website by joao-vasconcelos 10 months ago
- ci: dockerizes container (fixes: vercel/next.js#54093) — committed to crate-box/crate by dangminhngo 10 months ago
@michalvadak I verified the application runs correctly when removing the HOSTNAME env var:
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
toENV HOSTNAME 0.0.0.0
, orENV HOSTNAME ::
? Next now listens onlocalhost
, rather than0.0.0.0
, whenHOSTNAME
is set tolocalhost
😃 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.
@timneutkens you may want to update other Docker examples as well https://github.com/vercel/next.js/commit/0084166caaba402c1f8218da48e32855bc7ee48b 😃