Next.js Discord

Discord Forum

How to Debug a Nextjs Dockerfile Deployment

Unanswered
VoidPointer posted this in #help-forum
Open in Discord
I've just created my first Nextjs docker image, using the example Dockerfile from the Nextjs repo, and all seemed OK, and it seems to start up fine, the state is "running" and no error, but when I go to localhost:3000, I get localhost refused to connect.

I have what looks like quite a long and detailed guide to set up debugging in VSCode, but was wondering if any old hands know some common failure points I can check quickly before going through all that.

11 Replies

Saint Hubert Jura Hound
Can u show the output for the container of docker ps and ur dockerfile?
Here is ps:
3203ef71db44   nextjs-standalone-image:latest   "docker-entrypoint.s…"   9 seconds ago   Up 8 seconds   3000/tcp   trusting_dhawan

Dockerfile attached. I don't want to drag anyone into a detailed analysis before I get round to that though, just checking if there are any well known points of failure etc.
Oh hang on
You dont have a port exposed
You need to run docker run with -p flag
That 3000/tcp is showing the internal container port
When you run it with the p flag check it again youll see the difference
Cool, thanks. It's that kind of problem recognition I was hoping for. brb
@Saint Hubert Jura Hound When you run it with the p flag check it again youll see the difference
Thank you. That was rather stupid of me, because I checked Docker Desktop to see if the build command worked and totally overlooked the instruction right below that, which was docker run -p 3000:3000 nextjs-standalone-image