How To Write A Dockerfile
How To Write A Dockerfile
How To Write A Dockerfile
4/4/24
docker-file
Note: you can add the dependencies of your application in build stage.
Dockerfile
FROM node:14
WORKDIR /app (This sets the working directory inside the Docker container where
subsequent commands will be executed.)
3. COPY package*.json ./ (This copies the package.json and from your local
directory into the working directory in the container.)
4. RUN npm install (This runs the npm install command inside the container to
install the application dependencies specified in package.json.)
5. COPY . . (This copies the rest of the application code from your local directory into
the working directory in the container.)
6. EXPOSE 3000 (This instruction informs Docker that the container listens on port
3000 at runtime.)
7. CMD [“node”,”app.js”] (This specifies the command to run when the container
starts. In this case, it runs the Node.js application using the app.js file.)