docker node code example
Example 1: dockerfile for nodejs
# Choose the Image which has Node installed already
FROM node:alpine
# COPY all the files from Current Directory into the Container
COPY ./ ./
# Install the Project Dependencies like Express Framework
RUN npm install
# Tell that this image is going to Open a Port
EXPOSE 8080
# Default Command to launch the Application
CMD ["npm", "start"]
Example 2: docker node alpine
# Copy and paste to pull this image for the latest
docker pull node
# more specific use this line
# docker pull node:<version>-alpine
docker pull node:14.4-alpine3.11
Example 3: nodejs docker
FROM node:boron
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
CMD ["npm","start"]