I am following this tutorial: https://docs.docker.com/get-started/02_our_app/
When I updated my app.js file as mentioned in the tutorial (it's just a label change) then rebuilt and ran my image, Docker successfully runs the app but when I access localhost:3000 it gives me an error. The app was working fine before but now even if I download a fresh copy of the sample project and load it and follow the instruction from the start, accessing localhost:3000 is not showing me the app.
The error I get is this:
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
Any hints here on what went wrong? And how can I fix it?
Additional information:
I am using macOS with an m1 chip.
Here is my Docker file code:
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
here is the command I run to build and run my Docker:
docker build -t getting-started .
docker run -p 3000:3000 getting-started
This is the log of Docker App when I click on the running container:
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/08/13 09:26:50 [notice] 1#1: using the "epoll" event method
2021/08/13 09:26:50 [notice] 1#1: nginx/1.21.1
2021/08/13 09:26:50 [notice] 1#1: built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
2021/08/13 09:26:50 [notice] 1#1: OS: Linux 5.10.25-linuxkit
2021/08/13 09:26:50 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/08/13 09:26:50 [notice] 1#1: start worker processes
2021/08/13 09:26:50 [notice] 1#1: start worker process 33
2021/08/13 09:26:50 [notice] 1#1: start worker process 34
2021/08/13 09:26:50 [notice] 1#1: start worker process 35
2021/08/13 09:26:50 [notice] 1#1: start worker process 36
Everything seems to be working except the localhost which was working fine until I modified the text and rebuilt the image and run it.
I have also placed the dockerfile in the correct location and have not modified any other file.