I have developed a server-api application.
When running the app on my localhost, only two simple commands are needed to get it up and running:
- npm install
- npm start
With just these commands, the app runs perfectly on port 3000.
Now, I am trying to dockerize my server in order to launch it using docker-compose.
Below is my Dockerfile for this purpose:
FROM node:14-alpine AS development
ENV NODE_ENV development
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
To build the image, I execute the following command:
docker build --tag server-api .
Once the build process is complete, I run the container using:
docker run -p 80:3000 server-api
The logs indicate that the app is running on port 3000 and prompt me to connect to localhost:3000 to review my server-api app. However, upon checking port 80 on my computer, nothing happens.
What could be causing this issue?
I attempted to gather more information by connecting to the container with the following command:
docker exec -it <container_id> sh
But everything appears to be set up correctly and it's a straightforward app.
Any idea what mistake I might be making?