docker ( Run this command on terminal to check if docker is correctly installed )docker run -p 27017:27107 mongo ( Starting Docker Container for mongo )docker rmi <IMAGE_ID> —-force ( Removing docker image from your machine )docker ps ( Browses containers that are running currently )docker kill <CONTAINER_ID> ( To kill a container )docker images ( List all docker images present currently on your machine )docker run -p 27018:27017 mongo
# mac's port : Docker container's port ( Docker container's port for a process is defined in docker image of that process
docker exec -it <CONTAINER_ID> ssh ( Now you are inside docker container ) can ls , cd to this machine.Dockerfile
# Base Docker Image which already has nodejs installed
FROM node:22-alpine
# Dir in Docker Container which will have all ur files and folders for ur project
WORKDIR /app
# Copy everything in this Directory to Docker Container
COPY . .
RUN npm install
EXPOSE 3000
# Till here image is created
# When container starts what do u want to run
CMD ["node","index.js"]
docker build -t node-app-dockerimage .
# step 1 :
docker login # Login to your docker account
# step 2 :
docker build -t ritikaxg/node-app-dockerimage . # If you build your image with your docker username you can push it to hub.docker.com
docker push ritikaxg/node-app-dockerimage # Pushing image to hub.docker.com
docker run -p 3000:3000 ritikaxg/node-app-dockerimage # Using this command anyone an start your process (docker image) at port 3000